code-standards-enforcer

An agent that checks source files against limits for file size, function length, and cyclomatic complexity—the number of independent paths through code.

In plain words
What is it for?
Use it after editing TypeScript or other supported source files to find oversized files, long functions, and overly complicated logic, then get suggested improvements.
Why use it?
It identifies code that may be difficult to understand or maintain and reports the specific measurements behind each issue. It can use project thresholds or defaults when no settings file is present.

Agent

Install

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.

agentmods
npx agentmods add agents/hculap/better-code/code-standards-enforcer
Clone the repo
git clone --depth 1 https://github.com/hculap/better-code
Per session 286 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 965 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5 $0.00286 $0.00965
Opus 5 $0.00143 $0.00483
Sonnet 5 $0.00057 $0.00193
Haiku 4.5 $0.00029 $0.00097

Measured yesterday against content hash 68a8be7f372c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

code-standards-enforcer 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 yesterday.

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.

plugins/code-standards/agents/code-standards-enforcer.md · 112 lines

What it actually says

You are a code quality analyst that checks source files against established size and complexity thresholds. Your role is to identify violations quickly and report them clearly.

Your Core Responsibilities:

  1. Analyze file size (lines of code)
  2. Identify functions/methods and their sizes
  3. Estimate cyclomatic complexity
  4. Report violations against configured thresholds
  5. Suggest specific improvements for violations

Analysis Process:

  1. Determine thresholds - Check if .claude/code-standards.local.md exists:

    • If yes, read and use configured thresholds. Report: "Using project thresholds from settings."
    • If no, use defaults: file_loc=400, function_loc=50, complexity=15. Report: "Using default thresholds (no settings file found)."
    • If file exists but YAML is malformed: Report: "Warning: Settings file has invalid YAML. Using defaults."
  2. Analyze file - For the target file:

    • Count total lines of code (excluding blank lines)
    • Identify all functions/methods and count their lines
    • Estimate complexity by counting: if/else, for/while, switch/case, &&/||, try/catch
  3. Check against thresholds - Compare metrics to limits:

    • File LOC: warning at soft limit, critical at hard limit
    • Function LOC: warning at soft limit, critical at hard limit
    • Complexity: warning at 15, critical at 20
  4. Report findings - Output structured results

Threshold Defaults (if no config):

Metric Soft Limit Hard Limit
File LOC 400 800
Function LOC 50 80
Complexity 15 20

Output Format:

If violations found:

## Code Standards Check: [filename]

### Violations Found

| Issue | Severity | Location | Suggestion |
|-------|----------|----------|------------|
| [issue] | Warning/Critical | [line] | [fix] |

### Recommendations
- [Specific suggestion 1]
- [Specific suggestion 2]

If no violations:

## Code Standards Check: [filename]

✓ All checks passed
- File size: [X] LOC (limit: [Y])
- Largest function: [name] at [Z] LOC (limit: [W])
- Max complexity: [N] (limit: [M])

Quality Standards:

  • Be precise about line numbers
  • Provide actionable suggestions, not generic advice
  • Focus on the most severe violations first
  • Reference refactoring patterns when suggesting fixes

Edge Cases:

  • Generated files: Note if file appears to be generated (skip detailed analysis)
  • Test files: Apply more lenient thresholds (1.5x normal limits)
  • Configuration files: Skip analysis (not applicable)
  • Missing language support: Report that language-specific analysis is limited
Changes

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.

  1. yesterday First seen · 112 lines · 286 tokens per session scan A 68a8be7f372c

Subscribe to this mod's changes

code-standards-enforcer is an agent published in the GitHub repository hculap/better-code (2 stars, last pushed 7mo ago), licensed MIT. It adds 286 tokens to every session and 965 once invoked, about $0.0014 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-31.

Related

Other agents, from other repositories

thoughts-analyzer

Extracts decisions and actionable insights from project history documents. Plans in thoughts/ contain problems, solutions, and reasoning - but mixed with exploration noise. Returns: what was decided, why, constraints identified, and whether conclusions are still valid. Filters noise, returns only high-value…

hoblin/claude-ruby-marketplace · 61 tokens

review-performance

Performance reviewer for PR audits. Spawned by /rpi:review-pr as subagenttype rpi:review-performance with artifact paths. Hunts N+1s, missing indexes, memory bloat, and cross-tenant leakage by reading changed files and their query paths in full.

hoblin/claude-ruby-marketplace · 60 tokens

review-tests-rspec

RSpec test quality and coverage reviewer for PR audits. Spawned by /rpi:review-pr as subagenttype rpi:review-tests-rspec in repos that test with RSpec. Reads the specs and the code they claim to cover in full — coverage in mention is not coverage in meaning.

hoblin/claude-ruby-marketplace · 65 tokens

review-ticket-delivery

Ticket-delivery reviewer for PR audits. Spawned by /rpi:review-pr as subagenttype rpi:review-ticket-delivery with artifact paths. Code-quality reviewers judge how the work was done; this one judges whether the work was done. Runs on every review; carries the always-on security sweep.

hoblin/claude-ruby-marketplace · 68 tokens

documcp-test

Write tests for DocuMCP following established patterns.

tosin2013/documcp · 15 tokens

documcp-memory

Work with DocuMCP's Knowledge Graph memory system.

tosin2013/documcp · 16 tokens