claude-project-optimizer
AGENTS.md0 starsChanged 4 months agoMITView on GitHub
A Claude Code plugin that onboards new project directories. The SessionStart hook offers onboarding once per directory; the skills do the work. Three layers, deliberately separated: - scripts/session-start.sh — the hook. Read-only by contract. Decides whether to offer, never what to change. - scripts/scan-project.sh — all deterministic detection, emitted as JSON. Facts live here so skills spend questions only on what a script cannot know. - skills/*/SKILL.md — judgment. Reasons over scan JSON, proposes, applies. State lives outside the repo…
- Deletes or force-pushes
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,774 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
We split this AGENTS.md into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 75
Read them as data (while IFS= read -r -d '') and quote every use.
- Distinctive: line 77
Never let the hook write anything.
- Very specific: line 79
Never put die/exit in a function called from a command substitution — it kills only the subshell and the caller continues with an empty …
- Very specific: line 82
Read .claude/dean-guidelines.md before starting work and follow it.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
project-optimizer
A Claude Code plugin that onboards new project directories. The SessionStart hook offers onboarding once per directory; the skills do the work.
Commands
| Task | Command |
| Load for testing | claude --plugin-dir . |
| Scan a project | bash scripts/scan-project.sh <path> [--no-github] |
| Inspect state | bash scripts/registry.sh list |
| Reset a directory | bash scripts/registry.sh remove <abs-path> |
| Run tests | bash tests/run.sh |
Architecture
Three layers, deliberately separated:
scripts/session-start.sh— the hook. Read-only by contract. Decides whether to offer, never what to change.scripts/scan-project.sh— all deterministic detection, emitted as JSON. Facts live here so skills spend questions only on what a script cannot know.skills/*/SKILL.md— judgment. Reasons over scan JSON, proposes, applies.
State lives outside the repo at ~/.claude/project-optimizer/registry.json,
keyed by absolute path. session-start.sh and registry.sh must canonicalize
paths identically (cd … && pwd) or entries silently never match.
references/ is shared by the onboard and audit skills. Moving a file there
breaks both — update the ${CLAUDE_PLUGIN_ROOT}/references/… pointers in each.
Gotchas
- Hook and plugin changes require a full Claude Code restart. Editing
hooks/hooks.jsonor the hook script has no effect on the running session. claude plugin updatecompares the version string, not the commit. Withversionunchanged it reports "already at the latest version" and installed copies stay pinned at the sha they were installed from, however many commits the source has moved. Bumpversionin BOTH.claude-plugin/plugin.jsonand.claude-plugin/marketplace.json(they must match) or a fix never reaches anyone who installed from the marketplace — including you.- SessionStart also fires on
compactandclear. The hook filters on.source; without that filter the offer re-injects mid-task. Verified: the payload really does carrysource(alongsidecwd,session_id,transcript_path,hook_event_name), andclaude -p "/clear"produces two SessionStart events —startupthenclear— from which the hook emits exactly once.resumeis deliberately allowed through; onlycompact|clearare suppressed. - Reaching each source for testing:
startupis any normal run,resumeisclaude -c,clearisclaude -p "/clear".compacthas no headless trigger —/compactas a prompt yields onlystartup, and auto-compaction needs a full context window. It shares thecompact|clearbranch thatclearexercises, so it is covered by construction rather than observed. - macOS ships neither
timeoutnorgtimeout—run_boundedfalls back to a watchdog. Do not assumetimeoutexists. - BSD
xargs -Itruncates its constructed argument at 255 bytes, silently breaking probes on long paths. Prefer awhile readloop. - Plugin
hooks.jsonuses the wrapped form ({"description", "hooks": {…}}), not the flat settings form. The plugin-dev schema validator only understands the flat form and will report a false failure. Verified correct at runtime: Claude Code logsRead hooks.json for plugin project-optimizer (enabled=true). ${CLAUDE_PLUGIN_ROOT}is NOT set in the Bash tool's environment. It is expanded upstream — inhooks.jsoncommand strings, and by the Skill tool when it injects aSKILL.md. So the variable form is correct inside skills and hooks, and broken anywhere it reaches a shell unexpanded. A command failing with/scripts/…: No such file or directory(note the leading slash) means the variable was empty, which in practice means the text came from reading a file rather than from skill injection. Use repo-relative paths in prose and docs.
Do not
- Never interpolate a filename into a command string. Filenames from
git ls-filesare untrusted — a repo can containa"; rm -rf ~; echo ".txt. Read them as data (while IFS= read -r -d '') and quote every use. This was a real vulnerability inscan-project.sh;tests/run.shguards it. - Never let the hook write anything. Its read-only contract is what makes firing broadly acceptable.
- Never put
die/exitin a function called from a command substitution — it kills only the subshell and the caller continues with an empty value.
Read .claude/dean-guidelines.md before starting work and follow it. Claude Code loads it automatically through CLAUDE.md; other agents must open it themselves.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

