sloppy
AGENTS.md147 starsChanged 57 days agoMITView on GitHub
Hooks that make Claude Code check its own work, rulesets that teach every agent what this project flags, and an MCP server they can call on demand. ← Back to the README · All documentation A ruleset tells the agent what to avoid, and the MCP server lets it check when it remembers to. Neither makes it check. Hooks do: Claude Code runs Sloppy itself, after every edit and before the agent is allowed to call the task done, whether…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,736 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
2 rules. About 0 are common, 1 is distinctive, and 1 is 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.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 28
Only what the change introduced is ever reported.
- Very specific: line 132
Commit .ai/guidelines/sloppy.blade.php.
≈ “Common” is an estimate: at least 1 in 5 of the 16,597 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
Coding agents
Hooks that make Claude Code check its own work, rulesets that teach every agent what this project flags, and an MCP server they can call on demand.
← Back to the README · All documentation
Let the agent check itself
A ruleset tells the agent what to avoid, and the MCP server lets it check when it remembers to. Neither makes it check. Hooks do: Claude Code runs Sloppy itself, after every edit and before the agent is allowed to call the task done, whether or not the model thought to ask.
vendor/bin/sloppy agents install # or: php artisan sloppy:agents
vendor/bin/sloppy agents install --local # .claude/settings.local.json, out of git
vendor/bin/sloppy agents install --dry-runThat adds two hooks to .claude/settings.json and writes the ruleset into
CLAUDE.md as sloppy:rules would:
| When | What runs | What the agent sees |
After every Edit, Write or MultiEdit of a PHP file | sloppy hook post-edit | Findings that edit introduced in that file, compared with HEAD, while the code is still in front of it |
| When the agent tries to finish | sloppy hook stop | New findings at or above fail_on across the whole change. The agent is sent back to fix them |
Only what the change introduced is ever reported. An agent editing one method in a legacy file is not told about the twelve problems the file already had, because an agent told about them goes and "fixes" code nobody asked it to touch.
Tests are covered too, although the analyser never scans them. When the agent
edits a test file, SL503 compares it with HEAD, so
a test skipped, stripped of assertions or given assertTrue(true) to make it
pass is fed back the same way. A method left as // ... existing code ... or
throw new Exception('Not implemented') is SL112.
The Stop hook blocks once. If the agent tries to finish again, Claude Code marks the retry and Sloppy lets it through, listing whatever is left in the transcript. A false positive costs one round trip, not the session. And every way the hook could fail to run — no git, no commits yet, a broken config — lets the agent carry on, with a note in the transcript. A broken analyser never traps an agent.
What the model reads is plain text, capped at ten findings:
Sloppy: this edit to app/Services/Billing.php introduced 1 finding.
- app/Services/Billing.php:42 SL107 Swallowed Exception (high): The catch block for Throwable discards the exception...
Fix: Handle the failure or let it travel...Installing is safe to repeat. Your permissions, environment and other hooks
are left exactly as they were. Sloppy's own entries are found by their command
and replaced in place, and a settings file that is not valid JSON is refused
rather than rewritten. In a project with Sloppy in vendor/, the hooks call
php "${CLAUDE_PROJECT_DIR}/vendor/bin/sloppy", so the committed file works on
every checkout. With a global or phar install they call the binary that
installed them.
"New" means new compared with HEAD, so uncommitted work from before the
session counts as part of the change. That is the same rule sloppy diff uses.
Rules for coding agents
The cheapest finding is the one that never gets written. sloppy:rules writes
this project's rules where the agents already look, before they write anything:
php artisan sloppy:rules # CLAUDE.md, or Boost's guidelines
php artisan sloppy:rules --format=cursor --format=agents
php artisan sloppy:rules --format=copilot --format=windsurf
php artisan sloppy:rules --stdout # print insteadEach format knows the file its tool reads, so --output is only for the
unusual case:
--format= | Writes |
claude (default) | CLAUDE.md |
boost (default with Laravel Boost) | .ai/guidelines/sloppy.blade.php |
cursor | .cursorrules |
agents | AGENTS.md |
copilot | .github/copilot-instructions.md |
windsurf | .windsurfrules |
markdown | sloppy-rules.md |
json | sloppy-rules.json |
The Markdown formats merge into whatever is already there. json has no
marked block to merge into, so it refuses to overwrite an existing file unless
you pass --force.
The file describes your configuration -- your paths, your threshold, the rules you turned off, the ones skipped because you do not use their framework -- and gives each rule a line an agent can act on:
### SL107 Swallowed Exception
- Category: Error handling, severity: high
- Flags: A catch block that discards the exception ...
- Why it costs: A swallowed exception turns a bug into a silent wrong answer ...
- Write it this way instead: Handle the failure or let it travel. If you catch,
log the exception as the previous one and rethrow something meaningful --
never return null in place of an answer.Existing files are respected: the generated rules go inside a marked block, appended the first time and replaced in place afterwards, with everything outside the markers left exactly as your team wrote it. Regenerate it from the scheduler or a git hook and your team's own notes survive every run.
With Laravel Boost
Laravel Boost owns CLAUDE.md, AGENTS.md
and the rest in the projects that use it: it regenerates them on
boost:update, and its docs suggest keeping them out of git. A block merged
into those files survives the regeneration but is never committed, so a
teammate who clones the repository never gets it.
So where Boost is installed -- laravel/boost in composer.json, or a
boost.json -- sloppy:rules writes a Boost guideline instead, and Boost puts
it into every agent file it manages:
php artisan sloppy:rules # writes .ai/guidelines/sloppy.blade.php
php artisan boost:update # composes it into CLAUDE.md, AGENTS.md, ...Commit .ai/guidelines/sloppy.blade.php. The file is Sloppy's own: each run
replaces it, and it refuses to replace one it did not write unless you pass
--force. The rules are wrapped in @verbatim, because Boost renders
guidelines through Blade. Pass --format=claude to write CLAUDE.md as
before.
Your architecture, before the first file
A project that declares its architecture gets one more section in every ruleset: each role, where its classes live, what their names end in, and the policy it is held to, written as instructions:
### action
One use case, behind one public method. Lives in `App\Actions`, and its names end in `Action`.
- Never depend on: controller.
- Public methods: handle, execute, as*, ...It also names the module boundaries and the paths where every class must play
a role, and tells the agent to ask sloppy architecture place (or the MCP tool
sloppy_place) before creating a file. With the hooks installed, a class the
agent adds in the wrong place, or a dependency that crosses a layer, is fed
back on the edit that made it. A project that declares nothing gets the same
rules file as before.
Your custom rules teach the agents too
A custom rule is not a second-class citizen here. When the ruleset is
generated, a rule with no shipped advice falls back to its own
description(), so whatever that method returns is what lands in CLAUDE.md
in front of the model:
public function description(): string
{
// This sentence is what the agent reads. Write it as an instruction.
return 'Domain classes must not call facades. Inject the dependency '
.'through the constructor instead, so the class can be tested '
.'without booting the framework.';
}Written as a label -- "no facades in domain" -- it tells the agent a rule exists. Written as an instruction, it tells the agent what to write instead, which is the difference between a rule that gets tripped and a rule that gets followed. See Custom rules for the class itself.
MCP server
Agents that speak the Model Context Protocol can check their own work:
vendor/bin/sloppy-mcp # or: php artisan sloppy:mcpRegister it with your editor or agent, for example in .mcp.json:
{
"mcpServers": {
"sloppy": {
"command": "vendor/bin/sloppy-mcp",
"args": []
}
}
}Seven tools:
| Tool | What it answers |
sloppy_scan | What is wrong with these files, right now |
sloppy_diff | What did this change introduce, as opposed to inherit |
sloppy_rules | What does this project flag, and what should I write instead |
sloppy_health | What shape is this codebase in, before I touch it |
sloppy_architecture | What role does this class play, what may it touch, and which roles depend on which |
sloppy_place | Where does the class I am about to create belong, and what is it called |
sloppy_architecture_prompt | What do I need to write this project's architecture down from the team's own description |
The server's own instructions tell the agent to call sloppy_diff before
reporting a task finished, which is the moment the finding is cheapest to fix,
and sloppy_place before creating a class.
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.

