Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/adriannoes/awesome-agentic-ai/agentic-clean-codegit clone --depth 1 https://github.com/adriannoes/awesome-agentic-aiWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/adriannoes/awesome-agentic-ai/agentic-clean-code)<a href="https://agentmods.dev/rules/adriannoes/awesome-agentic-ai/agentic-clean-code"><img src="https://agentmods.dev/badge/rules/adriannoes/awesome-agentic-ai/agentic-clean-code.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00692 | $0.00692 |
| Opus 5 | $0.00346 | $0.00346 |
| Sonnet 5 | $0.00138 | $0.00138 |
| Haiku 4.5 | $0.00069 | $0.00069 |
Grade A, and why
agentic-clean-code scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 75 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Agent Clean Code
The primary reader of this code is an AI agent. Optimize for grep navigation, single tool-call comprehension, and headless test loops.
Size and structure
- Functions: 4–30 lines; split if longer.
- Files: under 500 lines; ideal 200–300. Split by responsibility.
- One responsibility per module (SRP).
- Follow framework conventions (Rails, Django, Next.js, etc.) so paths are predictable.
- Prefer small focused modules over god files.
Grep-friendly names
- Names must reveal intent and be distinct in the codebase.
- Avoid generic names:
data,process,handler,Manager,Service,util,helper. - Prefer specific names:
UserRegistrationValidator,InvoiceLineItemTotal. - Target:
rg "<symbol>"returns fewer than 5 hits; if not, rename or namespace.
Types
- Explicit types everywhere the language supports them.
- No untyped public APIs (
any, bareDict, untyped function signatures). - Typed code gives the agent immediate contracts and reduces inference errors.
DRY and control flow
- No duplicated logic across files — extract shared functions or modules.
- Named constants instead of magic numbers.
- Early returns and guard clauses; max 2 indentation levels.
- Prefer pattern matching / guard clauses over deep nesting.
Comments (provenance, not narration)
- Write WHY and provenance, not WHAT the syntax does.
- Keep agent-written comments on refactor — do not strip them.
- Document non-obvious constraints: upstream bugs, business rules, protocol quirks.
- Reference issue numbers when logic exists because of a specific bug or decision.
- Docstrings on public APIs: intent + one usage example.
- Skip obvious comments (
// increment counterabovecount++).
Errors
- Error and exception messages must include the offending value and expected shape.
- Bad:
raise ValueError("invalid input") - Good:
raise ValueError(f"invalid input: received {x!r}, expected non-empty string of digits")
Testability
- Inject dependencies through constructor, parameter, or context — not hidden globals.
- Wrap third-party libraries behind a thin project-owned interface when they may be swapped.
- Mock external I/O (API, DB, filesystem) with named fakes, not scattered inline stubs.
- Every new public function gets a test; every bug fix gets a regression test.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 4d ago First seen · 75 lines · 692 tokens per session scan A 6b1b3b94b786
agentic-clean-code is a cursor rule published in the GitHub repository adriannoes/awesome-agentic-ai (54 stars, last pushed 6d ago), licensed MIT. It adds 692 tokens to every session, about $0.0035 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other cursor rules, from other repositories
kotlin-springboot-rules
Cursor rule "kotlin-springboot-rules" from holtwood/awesome-cursorrules-zh, covering 项目结构与组织, 编码风格与约定, 地道的 kotlin 用法 and 实现模式与设计.
nestjs-general-guidelines
在 'src' 目录中指定 NestJS 特定的架构原则、模块化设计和测试实践。.
app-router-patterns
Next.js 14+ App Router patterns — Server Components, Client Components, Route Handlers, Server Actions, and metadata API.
nestjs-core-module-guidelines
为 NestJS 中的核心模块强制执行特定指导原则,专注于全局过滤器、中间件、守卫和拦截器。.
laravel-package-coding-standards
Cursor AI 编程规则精选集 | 132+ 规则,覆盖前端/后端/AI/DevOps 等 32 个领域.
code-style-and-improvements
Cursor AI 编程规则精选集 | 132+ 规则,覆盖前端/后端/AI/DevOps 等 32 个领域.