Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

codebase-hygiene

Agent skills that stop your coding agent from adding a fifth copy of the same function.

Coding agents are very good at adding code and close to useless at consolidating it. Ask for a feature and you get a feature. No agent volunteers a pull request that says "we have this helper in four places, here is one." So the codebase stops growing and starts accumulating.

This repo covers the three moments where you can actually intervene.

Skill When it runs What it does
reuse-first While building Searches for an existing equivalent before writing a new helper
duplication-review At the PR Checks what the diff adds against what the repo already has
duplication-sweep On a schedule Sweeps for accumulated duplication and dead code, ranked by payoff

They work independently. Adopt one, or all three.

Install

Claude Code

/plugin marketplace add answersamir/codebase-hygiene
/plugin install codebase-hygiene@samir-skills

GitHub Copilot CLI

copilot plugin marketplace add answersamir/codebase-hygiene
copilot plugin install codebase-hygiene@samir-skills

Everything else, by copying the folders

Every skill here is a plain Agent Skills folder, so installing is just putting skills/* in the directory your tool reads.

git clone https://github.com/answersamir/codebase-hygiene.git
cd codebase-hygiene

Then copy into whichever path applies:

Tool Project-level Personal
Claude Code .claude/skills/ ~/.claude/skills/
GitHub Copilot (CLI, VS Code, JetBrains, cloud agent, code review) .github/skills/, .claude/skills/, .agents/skills/ ~/.copilot/skills/, ~/.agents/skills/
VS Code (agent mode) .github/skills/, .claude/skills/, .agents/skills/ ~/.copilot/skills/, ~/.agents/skills/
Cursor .cursor/skills/, .agents/skills/ ~/.cursor/skills/, ~/.agents/skills/
OpenAI Codex .agents/skills/ ~/.agents/skills/
Gemini CLI .gemini/skills/, .agents/skills/ ~/.gemini/skills/, ~/.agents/skills/

For example, personal install for Claude Code:

cp -r skills/* ~/.claude/skills/

Two shortcuts worth knowing:

  • .claude/skills/ is read by Claude Code, Copilot, VS Code, and Cursor. One directory covers four tools.
  • .agents/skills/ is read by Copilot, VS Code, Cursor, Codex, and Gemini CLI, but not Claude Code. If you want one project directory for everything, put the files in .agents/skills/ and symlink .claude/skills to it.

Using them

While building

reuse-first triggers on its own when the agent is about to write a helper. To force it:

Use reuse-first before you add that formatter.

The useful output is not just "found one." It is the list of what the agent searched for, which tells you how much to trust a "nothing exists" claim.

At the PR

Use duplication-review on this branch against main.

It reports a one-line verdict, then ranked findings with file:line for both the new code and the existing equivalent.

The agent half catches semantic duplication, meaning the same behavior wearing a different shape. Pair it with a CI check for the textual half, which is cheaper and never forgets to run. Configs and a rollout plan that survives a real codebase are in references/ci-guardrails.md.

On a schedule

Use duplication-sweep on src/api. Report only, no PR.

Scope every run to one directory or one category, and rotate the scope. A sweep of the whole repo produces a report nobody reads.

It deliberately does not open a pull request. Finding duplication is cheap and safe; consolidating shared code is neither. A human picks what to act on.

Worth putting on a weekly timer. Logging each run's numbers to docs/sweeps/ turns a chore into a trend line, which is the part that actually tells you whether things are improving.

Why

GitClear analyzed 623 million code changes and found that moved code, which is roughly what refactoring looks like in a diff, fell from 21% of changes in 2022 to 3.8% in 2026. Copy-pasted code went the other way, 9.4% to 15.7%. Function connectivity, meaning how often new code calls into code that already exists, dropped 35% since 2023.

Worth noting on the data: GitClear sells code-analysis tooling, and their dataset does not tag which commits were AI-written, so it shows correlation across the same period rather than proving causation. The behavior these skills address is observable without the study anyway.

Contributing

Skills live in skills/<name>/SKILL.md and follow the Agent Skills specification. Frontmatter is kept to name, description, and license so the folders stay portable across tools.

Issues and pull requests welcome, particularly reports of false positives from duplication-review. A duplication check that cries wolf gets muted, and then it catches nothing.

License

MIT. See LICENSE.

About

Agent skills that stop your coding agent from adding a fifth copy of the same function. Build-time reuse checks, PR-time duplication review, and a scheduled sweep.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors