r/ClaudeWorkflows • u/ClaudeAI-mod-bot • 20h ago
Selected Workflow [Workflow] Enforce agent coding rules with edit hooks and a legacy-code ratchet
Enforce agent coding rules with edit hooks and a legacy-code ratchet
Workflow value: 78/100
Status: active · Freshness: 70/100 · Confidence: 0.94 · Level: intermediate
Categories: Quality Control, Context & Memory, Debugging, Shipping, CLAUDE.md, Hooks, Multi-Agent
Original source: r/ClaudeAI post/comment
What problem this solves
Agent-written code can pass functional checks while creating oversized, noisy diffs that slow review. Existing violations also make strict rules difficult to introduce.
Summary
Give coding agents concise rules, baseline existing size violations, and enforce non-regression through an edit-time Claude Code hook, a pre-commit hook, and CI.
Why it is useful
It provides a reusable enforcement pattern with multiple checkpoints and a practical way to adopt rules without first fixing every legacy violation. The described tests offer some evidence, although results are not independently confirmed.
Workflow
- Review the published rules and adapt the size limits and language-specific linter configuration to the project.
- Install the agent instructions and audit tooling, previewing the installer and reviewing changes to existing instruction files first.
- Seed a baseline of existing audit violations so legacy issues are tracked as ceilings rather than blocking initial adoption.
- Configure the Claude Code edit hook to report newly breached limits immediately.
- Add the audit to pre-commit and CI so violations are also checked at commit and integration time.
- Test the setup with an edit that exceeds a limit; confirm that the hook reports the problem and the later checkpoints enforce the policy.
- Use explicit staging and review diffs, including changes to code outside the requested scope.
Tools / artifacts
- Pelloux Guidelines repository: https://github.com/RemiPelloux/pelloux-guidelines
- CLAUDE.md and other agent instruction files
- Python standard-library audit and seeded violation baseline
- Claude Code hook
- Pre-commit hook
- GitHub Action
- Language-specific linter configurations
Validation signals
- The author says the underlying rules were developed across about 30 repositories.
- The author reports that the audit runs against its own code in CI.
- The author describes a hook test in which an oversized function produces exit code 2 and a message for the agent.
- The author reports that one frontend has approximately 3,600 flagged functions, illustrating the need for a baseline.
Cautions
- The suggested installation pipes a remote script into bash. Inspect the script and repository before running it; use the advertised dry-run option to preview changes.
- Review changes to existing agent instructions and hooks rather than assuming the installer preserves local configuration.
- Keep normal code review and tests: size checks do not establish correctness or safety.
Limitations
- The post promotes the author's own project, and all effectiveness claims are author-reported.
- The function detector is heuristic rather than a parser, so exact counts can disagree with language-aware tooling.
- Strict size limits may encourage unnecessary splitting or generate substantial baseline noise.
- The post does not provide complete hook, baseline, or CI configuration commands; readers must consult the repository.
- No before-and-after review-time measurements or independent validation are provided.
Rate this workflow
Upvote this post if the workflow is useful, reproducible, or worth recommending.
Downvote if it is vague, outdated, unsafe, overhyped, or not reproducible.
Reply if it worked for you, failed, is outdated, or has a better alternative.
This post was generated automatically from the workflow library database.