rulesync icon indicating copy to clipboard operation
rulesync copied to clipboard

Feature Request: let the claudecode target emit .claude/rules/ without the root CLAUDE.md

Open acelarski opened this issue 2 months ago • 0 comments

Problem

The claudecode target's rules feature writes two outputs from a single switch. From docs/reference/file-formats.md (v17.0.0):

Rulesync writes the root rule to CLAUDE.md at the project root (also read from .claude/CLAUDE.md as an alternative root) / ~/.claude/CLAUDE.md (global, via --global)

non-root rules to .claude/rules/*.md (project) / ~/.claude/rules/*.md (global)

Claude Code reads CLAUDE.md when it is present and falls back to AGENTS.md when it is not. So in a repository that also enables agentsmd — or codexcli, which shares the project-root AGENTS.md — the generated CLAUDE.md is a second copy of a root rule Claude Code would have read from AGENTS.md anyway: one more generated file in every diff, for no change in behaviour.

That fallback is native, not a workaround. Claude Code v2.1.277 (2026-09-18) — changelog:

Added AGENTS.md support: in a project with no CLAUDE.md, Claude Code reads AGENTS.md instead; change it under "Project instructions" in /config (not yet on Bedrock, Vertex or Foundry)

And the memory documentation names exactly which files decide it:

  • Count, so Claude reads them instead of AGENTS.md: a CLAUDE.md, .claude/CLAUDE.md, or CLAUDE.local.md in your working directory or any directory above it
  • Don't count, and keep loading alongside AGENTS.md: your ~/.claude/CLAUDE.md, your organization's managed CLAUDE.md, and .claude/rules/ files

Both root files rulesync can write — CLAUDE.md and .claude/CLAUDE.md — shadow AGENTS.md; .claude/rules/*.md does not. The split this request asks for is the split Claude Code already makes.

Two caveats, neither of which removes the redundancy: the fallback is the claude-md-or-agents-md default of the Project instructions setting, and a user who sets claude-md-and-agents-md loads both files; and AGENTS.md is not read at all before v2.1.277 or in sessions that don't fetch feature flags (Amazon Bedrock and other third-party providers, telemetry disabled). An opt-out that stays opt-in leaves those users on today's behaviour.

Dropping rules from claudecode's feature list does suppress CLAUDE.md, but it suppresses .claude/rules/*.md along with it — and that is Claude Code's only scoped-rule mechanism (the paths frontmatter). There is currently no documented way to keep the scoped rules and drop the redundant root file.

Proposed solution

An opt-out for the root file on the claudecode target, leaving non-root rules untouched.

pi.contextFile already establishes the shape of a per-target override of the root context file, so the mechanism exists; what is missing is a way to say this target's root rule is already covered by AGENTS.md, do not write it again. A claudecode-specific flag would solve this case; a general per-target "skip the root file" option would also cover any other target that shares AGENTS.md.

Desired behaviour

  1. With the opt-out set, generate writes .claude/rules/*.md exactly as it does today, and writes no CLAUDE.md and no .claude/CLAUDE.md.
  2. Without it, behaviour is unchanged — the current output stays the default.
  3. With delete enabled, a CLAUDE.md generated by an earlier run is swept on the first run after the opt-out is set, rather than left behind as an orphan that still shadows AGENTS.md.
  4. The personal CLAUDE.local.md that is materialized next to the root file follows it: no root file emitted, none materialized.

Reference

Read at tag v17.0.0: docs/reference/file-formats.md (the claudecode and agentsmd emission rules, and pi.contextFile) and docs/guide/configuration.md (per-target features in object form).

acelarski avatar Sep 22 '26 18:09 acelarski