/codemyrules:codemyrulesfrom codemyrules
Converts project decisions, coding patterns, and agent-doc instructions into lint rules across JS/TS/Vue/Svelte (eslint-pattern-rules) and Java/Kotlin/Python/Go/C#/PHP/Rust/Ruby/PowerShell (backend-pattern-rules), then slims CLAUDE.md/AGENTS.md and sets up a silent lint feedback loop for Claude Code.
Ships in codemyrules. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
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, and the agent can still ignore it. A lint rule costs nothing until it is broken, and then it says exactly what is wrong. This skill turns a project's conventions into rules, slims the agent docs those rules now cover, and sets up a feedback loop so the agent meets the rules while it codes.
It is a manager over two skills and does not repeat their work:
eslint-pattern-rules: JavaScript, TypeScript, Vue, Svelte, including Node backends.backend-pattern-rules: Java, Kotlin, Python, Go, C#, PHP, Rust, Ruby, PowerShell and other languages ast-grep parses.Invoke each with the Skill tool when it is installed.
Otherwise ask the user for the path to its SKILL.md, read it, and follow it from there, with its references/ beside it.
Both have the same steps (1 detect, 2 pick, 3 design, 4 write, 5 verify, 6 agent-doc cleanup, 7 report), the same coverage labels and the same report shape.
Nothing is written to the project without the user's approval: no rule, config change, doc edit, hook or baseline. The mode question below is that approval for everything automatic mode builds. The sub-skills ask the same mode question; hand them the answer from step 0 so it is asked once.
Before anything else, ask one single-select AskUserQuestion (header Mode):
high risk candidate.When the user already said which mode in the request, skip the question. When the user said to go ahead with your recommendations, that is automatic. With nobody to answer and no such word, use manual and build nothing that needs a pick.
The project is the current working directory, unless the user names another folder. Do not look for it elsewhere: a copy of the same repository in another folder is not the project.
Look these up rather than asking:
package.json, tsconfig.json, .vue, .svelte, .ts, .js sources, and where they live (frontend/, apps/web/, the root).
Note its linter: ESLint (eslint.config.*, .eslintrc*), oxlint (.oxlintrc.json, .oxlintrc.jsonc, oxlint.config.ts, oxlint in the lint script), or Biome (biome.json, biome.jsonc).
ESLint or oxlint goes to eslint-pattern-rules, which takes the ESLint path whenever the project runs ESLint at all.
Biome is not supported yet: build nothing for that stack and say so in the report.pom.xml, build.gradle(.kts), pyproject.toml, go.mod, *.csproj, composer.json, Cargo.toml, Gemfile, and PowerShell sources (.ps1, .psm1, a PSScriptAnalyzerSettings.psd1).
Goes to backend-pattern-rules..yo-rc.json, .jhipster/, .openapi-generator/, @Generated, or DO NOT EDIT headers.
Note which source folders a generator owns: a rule still guards new code there, but existing hits are fixed in the generator's template or blueprint, and hand edits are lost on the next run..claude/codemyrules/baseline.json.
When it exists, run node <skill-dir>/scripts/measure.mjs report <project-dir> now, for step 7, and codemyrules status <project-dir> to see whether the loop's hooks still run.
Hooks that run copies from before the npm package, a CLI that is missing, or a package that is not pinned, are reinstalled in step 5 with the project's own loop.json.
A pinned version older than the global package is not updated on its own: name both versions in step 5 and let the user decide.Count with rg -c and rg --files, always with a path (with several -g globs the last matching one wins, so put exclusions like -g '!*.spec.ts' after the includes), and leave out vendored and generated folders (node_modules/, dist/, build/, target/).
A repository with both stacks: note each stack's root folder, so every candidate has one owner.
Done when every source root has its sub-skill, or the user knows which one has none.
Run each matched sub-skill's step 1 and its discovery (its step 2, through references/discovery.md) up to and including the labelling, unchanged except that the shared context from step 1 here is reused, not detected again.
Stop before its selection dialog: step 3 here selects once for both.
When the user named one convention, run only the sub-skill that owns its stack, and its step 2 as written.
Keep from each sub-skill, for steps 3 to 6:
Done when each sub-skill has labelled its candidates.
Merge every candidate from both sub-skills into one list: project candidates, built, not enabled, switched off and general ones together, never split by family (no separate call for general, bug-prevention or style rules).
Order it by the sub-skills' rules: coverage (documented, not enforced and built, not enabled first), then always-loaded agent-doc lines before on-demand ones, then risk, then fewest flagged files; general and switched off candidates after the project ones.
An agent-doc rule the agent does not load today (a linked file, a folder doc outside where it works) is where a rule changes the most, and an always-loaded line is where deleting prose saves context in every session.
Recommended is every candidate whose risk is below high, except switched off ones (someone decided against them) and general ones with no hits and no tool the project already runs for them.
covered candidates appear only as notes, and contradicted ones only as their question.
Automatic mode:
AskUserQuestion call, and only when there is something to ask: each contradiction as a single-select ("update the doc to match the code" or "enforce the doc"), and the high risk candidates as one multi-select ("These rules are high risk, which should I build?").Manual mode:
AskUserQuestion call with every candidate, multiSelect: true, up to 4 options per question and 4 questions per call.
Fill the questions in list order, frontend and backend in separate questions, each naming its side ("Which of these frontend rules should I build?").
Put (Recommended) at the end of each recommended option's label.
Each option's description is the why-sentence plus the flagged files and the risk; a general rule also names its standard value.Without the tool, list the candidates in chat, recommended ones marked, and ask for names. In manual mode, build nothing until the user answers.
Done when every candidate is built, picked, not picked, asked, or a note.
Hand each picked candidate to the sub-skill that owns its stack and follow that sub-skill's steps 3 to 6 for it: design, write, verify, agent-doc cleanup.
A built, not enabled or general candidate is a config change, as the sub-skill describes.
In automatic mode, answer the sub-skill's design questions with its recommended default, unless the answer changes a doc, and list each answer for step 7.
Note each rule's open hits on the real code from its verify step, and its layer (main config or suggestions layer), for steps 5 and 6.
A rule the existing code breaks goes into the sub-skill's suggestions layer at error, never into the main config at warning: at warning the loop would never show it, and these are the rules agents break by copying nearby code.
The agent-doc cleanup always asks, in both modes: it changes a doc.
In automatic mode, ask all doc edits from every picked candidate in one AskUserQuestion call after the builds, not one call per rule.
In the agent-doc cleanup, when the user keeps a one-line pointer, propose where it goes in the same question: a CLAUDE.md in the folder the rule applies to, or an instructions file with an applyTo glob such as .github/instructions/domain.instructions.md, rather than the root doc.
Then the pointer loads only when the agent works in that folder.
Offer the root doc as the other option when the rule applies to the whole repo.
Done when every picked candidate is built and verified, or reported as not built with the reason.
The loop runs the project's lint setup in Claude Code hooks: a guard before each edit and around each shell command, a fast check after each edit (also one made through a shell command), and a full check at the end of each turn.
It is private (.claude/settings.local.json and .git/info/exclude) and silent when clean.
references/feedback-loop.md explains it; read it before offering.
Offer it only when you are running in Claude Code, pi, opencode 2, the GitHub Copilot CLI or the Gemini CLI, and always pass the harness you are running in to the install command below: --harness claude, --harness pi, --harness opencode, --harness copilot or --harness gemini.
In pi, the guard asks through pi's confirm dialog, and pi loads the extension only in a trusted project, so say that in the report.
In opencode, the guard asks through opencode's permission prompt, and --auto approves it, so say that in the report.
In the Copilot CLI, the guard asks through Copilot's permission prompt, and in autopilot mode Copilot refuses a flagged edit, so say that in the report.
In the Gemini CLI, the guard asks through Gemini's approval prompt, a headless gemini -p run refuses a flagged edit but then hangs because of a Gemini bug (so headless runs need a timeout), project hooks run only in a trusted folder, and the installer refuses a .gemini/settings.json that git tracks, so say that in the report.
In any other harness, skip this step and the baseline, and say in the report that the feedback loop needs Claude Code, pi, opencode 2, the GitHub Copilot CLI or the Gemini CLI and is not available here.
Draft the config in a temporary file outside the project, as loop.json:
{
"linters": [
{ "name": "ast-grep", "format": "ast-grep", "command": ["node_modules/.bin/ast-grep", "scan", "-c", "sgconfig.suggestions.yml", "--json=compact", "{files}"], "extensions": [".kt", ".java"], "tier": "fast" },
{ "name": "eslint", "format": "eslint", "command": ["node_modules/.bin/eslint", "-c", "eslint.config.suggestions.mjs", "--format", "json", "{files}"], "extensions": [".ts", ".vue"], "tier": "full" },
{ "name": "ruff", "format": "ruff", "command": ["ruff", "check", "--output-format=json", "{files}"], "extensions": [".py"], "tier": "full" },
{ "name": "oxlint", "format": "oxlint", "command": ["node_modules/.bin/oxlint", "-c", ".oxlintrc.suggestions.json", "--format", "json", "{files}"], "extensions": [".ts", ".tsx"], "tier": "fast", "cwd": "frontend" },
{ "name": "psscriptanalyzer", "format": "psscriptanalyzer", "command": ["pwsh", "-NoProfile", "-NonInteractive", "-File", ".claude/codemyrules/pkg/skills/codemyrules/scripts/core/psscriptanalyzer.ps1", "-Settings", "PSScriptAnalyzerSettings.suggestions.psd1", "{files}"], "extensions": [".ps1", ".psm1"], "tier": "full" }
],
"protect": ["**/eslint.config.*", "**/.eslintrc*", "**/.oxlintrc*", "**/oxlint.config.*", "sgconfig*.yml", "ast-grep/**", "eslint-rules/**", "**/oxlint-rules/**", "**/detekt-baseline.xml"]
}
sgconfig.yml (or the command passes -c <path> to one), run the way the project runs it; without one every scan fails, so leave ast-grep out, and the installer refuses such a config; ESLint only through eslint_d when the project has it (["eslint_d", "--format", "json", "{files}"]).
oxlint qualifies as an installed binary (node_modules/.bin/oxlint, format oxlint).
Only an installed binary: node_modules/.bin/ast-grep or ast-grep on PATH.
A package runner (npx, npm exec, pnpm dlx, yarn dlx, bunx) resolves the package on every edit, about 0.4 s warm and seconds or a download cold, and a run past the time budget counts as clean, so the installer refuses one in the fast tier.npx, name the package @ast-grep/cli with -p and pin the version the project uses: npx ast-grep alone resolves an unrelated npm package.
The end-of-turn check runs both tiers, so list each linter once, in the fastest tier it qualifies for.-Settings naming the settings file the loop runs; pwsh 7 only, Windows PowerShell 5.1 cannot run the wrapper.
Every finding blocks, whatever its severity, so the settings file the loop runs lists in IncludeRules only the rules the project enforces.-c eslint.config.suggestions.mjs, -c sgconfig.suggestions.yml, -c .oxlintrc.suggestions.json, -Settings PSScriptAnalyzerSettings.suggestions.psd1, as in the example), so rules the existing code breaks still guard every changed line; without one, drop the -c.command is the project's own invocation with JSON output, and "{files}" is its own element.
extensions are the file types that linter covers in this project.apps/web/ with its own node_modules and eslint.config.mjs), add "cwd": "apps/web" and write command as it runs from there; list one entry per package that lints differently.
The linter then starts in that folder and gets only the edited files inside it, so another package's files never reach the wrong config.protect: paths relative to the project root for every file that decides what counts as a violation: lint configs (eslint.config.* including the suggestions config, .eslintrc*, .oxlintrc*, oxlint.config.*, sgconfig*.yml, detekt*.yml, ruff.toml, checkstyle.xml, .golangci.yml, **/PSScriptAnalyzerSettings*.psd1), rule folders (eslint-rules/**, oxlint-rules/**, ast-grep/**, PSScriptAnalyzerRules/**, the project's own rule-set module), baseline files, and architecture tests (*Arch*Test*, *TechnicalStructure*).
Leave out shared build files such as package.json, pom.xml or pyproject.toml, where an ask on every edit would be noise: the guard already asks for edits to the lint settings inside package.json, pyproject.toml, setup.cfg and tox.ini; mention in the report that lint settings inside other build files, such as plugin config in pom.xml or build.gradle, are not guarded.
.claude/codemyrules/ and .claude/settings.local.json are always guarded.The installer validates the config (formats, tiers, command as a list with "{files}", every -c or --config path existing, the command's tool installed (on PATH, or a path in the project), protect as a list) and refuses a broken one with a message per field, before it writes anything.
The installer copies the globally installed codemyrules npm package into .claude/codemyrules/pkg/, records its version and sha256 in pin.json, and the hooks run that copy, so an npm update reaches the project only when the installer runs there again.
Check it with codemyrules --version: when it is missing or older than this skill's version, the plan starts with npm install -g codemyrules@<this skill's version>, approved together with the loop, and run before the installer.
Run the installer as a dry run and show its plan:
node <skill-dir>/scripts/install.mjs <project-dir> --config <tmp>/loop.json
In automatic mode, run the same command with --apply and put the plan in the report.
In manual mode, ask one AskUserQuestion: install the loop as planned, or skip it.
Show the hook config, the files it creates and the .git/info/exclude lines in the question or its preview.
On a yes, run the same command with --apply.
With nobody to answer, do not install, and put the plan in the report.
Done when the loop is installed or declined.
Only when the loop was installed: write the open hits per rule from step 4 to a temporary JSON file, {"local/gen-no-direct-fetch": 4, "gen-no-clock-in-domain": 0}, and run:
node <skill-dir>/scripts/measure.mjs baseline <project-dir> --rules <tmp>/rules.json
Rules are keyed by their linter rule id; when two picked conventions share one (two no-restricted-syntax entries), they are counted together, so say so in the report or build one of them as a named custom rule.
It records the agent-doc tokens (characters / 4), split into always-loaded docs (root CLAUDE.md, AGENTS.md, GEMINI.md, the files they import with @path, and the root Copilot, Cursor and Windsurf files) and on-demand docs (folder agent docs, plus the Markdown files any agent doc links to, and the files those link to in turn), plus the rules and their open hits, in .claude/codemyrules/baseline.json.
A later run of this skill compares against it.
Done when baseline.json exists, or the loop was not installed.
Keep it short, frontend and backend apart:
measure.mjs report: always-loaded and on-demand doc tokens then and now, per rule its open hits at baseline and the failures logged since, and its advice linesPass the report's advice on as proposals, each with its numbers: a rule that keeps failing needs an up-front pointer, a rule caught mostly at the end of the turn belongs in the fast tier, and a doc line for a rule that never failed can likely go. Present the benefit honestly: the doc tokens removed matter only for always-loaded lines; the larger effect is fewer fix rounds, which shows up in the failure log and in review, not in the character count. Close with the sub-skills' step 7 round for any design questions answered on the user's behalf.
agents/openai.yaml (opens in a new tab)references/feedback-loop.md (opens in a new tab)scripts/cli.mjs (opens in a new tab)scripts/copilot.mjs (opens in a new tab)scripts/core/checks.mjs (opens in a new tab)scripts/core/lib.mjs (opens in a new tab)scripts/core/loop.mjs (opens in a new tab)scripts/core/psscriptanalyzer.mjs (opens in a new tab)scripts/core/psscriptanalyzer.ps1 (opens in a new tab)scripts/core/secret-patterns.json (opens in a new tab)scripts/core/snapshot.mjs (opens in a new tab)scripts/gemini.mjs (opens in a new tab)scripts/guard.mjs (opens in a new tab)scripts/install.mjs (opens in a new tab)scripts/lint-edited.mjs (opens in a new tab)scripts/lint-turn.mjs (opens in a new tab)scripts/measure.mjs (opens in a new tab)scripts/opencode.mjs (opens in a new tab)scripts/pi.mjs (opens in a new tab)scripts/shell-guard.mjs (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
JavaScript, TypeScript, Vue, Svelte, Java, Kotlin, Python, Go
lint-rules, agent-docs, claude-md, code-quality, pattern-rules
npx claudepluginhub clirimajeti/codemyrules --plugin codemyrulesOther plugins' skills for the same job