
Claude.md is full of lint rules in disguise
Every prose rule in CLAUDE.md, AGENTS.md or an instructions file is read in every agent session, whether the task needs it or not.
以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。
Every prose rule in CLAUDE.md, AGENTS.md or an instructions file is read in every agent session, whether the task needs it or not. The agent can still ignore it. A lint rule costs nothing until it is broken, and then it says exactly what is wrong.
codemyrules finds the conventions your code and docs already state, writes them as lint rules, slims the agent docs those rules now cover, and lets the agent meet the rules while it codes.
claude plugin marketplace add clirimajeti/codemyrules claude plugin install codemyrules@codemyrules
This also installs the two sub-skills codemyrules drives, eslint-pattern-rules and backend-pattern-rules, as dependencies.
Then ask in your own words. The skill is model-invoked, so there is no command to remember:
npx skills add clirimajeti/codemyrules npx skills add clirimajeti/eslint-pattern-rules npx skills add clirimajeti/backend-pattern-rules
The rules work in every harness. The feedback loop is offered only in Claude Code for now, see Harness support.
Copy skills/codemyrules/ into your agent's skills folder, for example ~/.claude/skills/codemyrules/, next to the two sub-skills. When a sub-skill is not installed, the skill asks for the path to its SKILL.md.
We inject java.time.Clock. Production code calls Instant.now(clock), never a bare Instant.now().
codemyrules offers it as a candidate labelled documented, not enforced, and on your yes writes an ast-grep rule with tests:
id: use-clock-injection language: Kotlin severity: error message: $T.now() without a clock (ADR 0043). Use $T.now(clock) instead. rule: pattern: $T.now() constraints: T: { regex: '^(Instant|LocalDate|LocalDateTime|ZonedDateTime|OffsetDateTime)$' }
The agent-doc line that said the same thing becomes a one-line pointer in the folder's CLAUDE.md. When the agent then writes Instant.now(), the feedback loop tells it within seconds:
src/main/kotlin/mail/MailSender.kt:42 use-clock-injection Instant.now() without a clock (ADR 0043). Use Instant.now(clock) instead.
Why Rules Instead of Prose
The defaults come from an experiment: 124 headless Claude Code sessions on two isolated copies of a real Kotlin/Spring backend. It compared a rule written as prose with the same rule as a lint rule plus the feedback loop. The tested rule was design-shaping (time through an injected Clock); a second, mechanical rule (lowercase log messages) was tested alongside.
So codemyrules recommends: for a mechanical rule, the rule only; for a design-shaping rule, the rule plus a one-line pointer in the folder-level CLAUDE.md.
The method, the harness to rerun it on your own repo, and related work are in agent-rules-bench.
Detects your stacks and maps each source root to its sub-skill.
Discovers candidates through each sub-skill: your code's majority patterns, your decision records, the rules written as prose in your agent docs, and well-known rules your linters have but you don't use yet.
Lets you pick from one selection, frontend and backend in separate questions. Nothing is built until you pick it.
Builds each pick through the sub-skill that owns its stack: design questions, the rule and its tests, verification on your real code. Then, for each line in your agent docs the new rule enforces, you choose to delete it, shorten it to a pointer, or keep it. A pointer you keep can move to a CLAUDE.md in the folder it applies to, so it loads only when the agent works there.
Offers the feedback loop as one approved step, after showing exactly what it installs.
Records a baseline: agent-doc tokens, rules and open hits, so a later run can show what changed.
Reports the rules, doc lines removed, the loop and the baseline, and on a re-run the before and after.
A rule your existing code already breaks goes into a suggestions layer (eslint.config.suggestions.mjs, sgconfig.suggestions.yml). CI stays green, and the feedback loop still applies the rule to new code, so the agent stops copying the old pattern.
Source Where
Decision records docs/adr/, docs/decisions/, notes/decisions/, ADR-*.md, CONTRIBUTING
Agent docs CLAUDE.md, AGENTS.md, GEMINI.md, .github/copilot-instructions.md, .github/instructions/, .cursor/rules/, .cursorrules, .windsurfrules
Docs linked from agent docs @file imports and Markdown links to repo files, one level deep
Code majority patterns, and code that goes around the project's own helpers
The Feedback Loop
Three tiers, each silent when clean:
To uninstall, delete .claude/codemyrules/ and the three codemyrules entries in .claude/settings.local.json. references/feedback-loop.md has the details.
Rules and doc cleanup Feedback loop
Claude Code yes yes
Codex, Copilot, Cursor and others yes not yet
Today, the feedback loop relies on Claude Code hooks. Support for Codex, pi, OpenCode and other harnesses is in progress. If your harness has hooks or a plugin API and you want it supported, open an issue.
Anything you have not approved: no rule, config change, doc edit, hook or baseline is written without your yes.
Build files and lockfiles, as in both sub-skills.
Your agent docs, except the lines you approve deleting, shortening or moving.
Development
skills/codemyrules/ ├── SKILL.md # the workflow ├── agents/openai.yaml # Codex picker metadata ├── references/ │ └── feedback-loop.md # tiers, what blocks, the guard, the log, uninstall └── scripts/ ├── install.mjs # installs the loop into a project (dry run by default) ├── measure.mjs # baseline and before/after report ├── guard.mjs # PreToolUse hook ├── lint-edited.mjs # PostToolUse hook, fast tier ├── lint-turn.mjs # Stop hook, all tiers ├── lib.mjs # shared hook code └── test/ # node:test suites
Run the tests:
node --test skills/codemyrules/scripts/test/*.test.mjs
Related
eslint-pattern-rules - the frontend sub-skill.
backend-pattern-rules - the backend sub-skill.
agent-rules-bench - the benchmark behind the defaults.
License
MIT
正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。