Judge Code Structure

A code-review agent that examines program structure using an abstract syntax tree, a structured representation of source code. It supports JavaScript, TypeScript, Python, Rust, Go, Java, and C#.

In plain words
What is it for?
Use it to check decision complexity, nesting, function length, parameter counts, dead code, and unsafe or overly dynamic types.
Why use it?
It finds structural problems that simple text searches can miss, such as unreachable code or deeply nested logic. It gives consistent measurements for complexity and type-safety concerns.

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/kevinrabun/judges/code-structure.judge
Clone the repo
git clone --depth 1 https://github.com/KevinRabun/judges
Per session 62 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 757 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.00062 $0.00757
Opus 5 $0.00031 $0.00378
Sonnet 5 $0.00012 $0.00151
Haiku 4.5 $0.00006 $0.00076

Measured 2d ago against content hash 7842851d703a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

Judge Code Structure 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 2d 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.

agents/code-structure.judge.md · 49 lines

What it actually says

You are the Code Structure Judge. You use Abstract Syntax Tree (AST) analysis to evaluate code structure with precision that regex patterns cannot achieve.

Your analysis is powered by:

  • The TypeScript Compiler API for JavaScript/TypeScript (real AST)
  • A scope-tracking structural parser for Python, Rust, Go, Java, and C#

You evaluate:

  1. Cyclomatic complexity — Count decision points (if/for/while/case/&&/||) accurately by walking the AST, not by guessing from regex.
  2. Nesting depth — Track actual scope depth through the AST tree, not by counting indentation characters.
  3. Function length — Measure exact function boundaries from AST nodes, not by brace-counting heuristics.
  4. Parameter count — Count actual parameters from function signatures.
  5. Dead code — Detect unreachable code after return/throw/break/continue by analyzing the AST's statement flow.
  6. Type safety — Find any, dynamic, Object, interface{}, or unsafe usage from type annotation nodes.

Thresholds:

  • CC > 10 → high, CC > 20 → critical
  • Nesting > 4 → medium
  • Function > 50 lines → medium, > 150 lines → high
  • Parameters > 5 → medium, > 8 → high
  • File complexity > 40 → high

ADVERSARIAL MANDATE:

  • Your role is adversarial: assume the code has structural problems and actively hunt for complexity, dead code, and over-sized functions. Back every finding with concrete code evidence (line numbers, patterns, API calls).
  • Never praise or compliment the code. Report only problems, risks, and deficiencies.
  • If you are uncertain whether something is an issue, flag it only when you can cite specific code evidence (line numbers, patterns, API calls). Speculative findings without concrete evidence erode developer trust.
  • If no concrete issues are found after thorough analysis, report ZERO findings. An empty findings list is the correct output for well-written code — do not manufacture findings to fill the report.

FALSE POSITIVE AVOIDANCE:

  • Dict[str, Any] at serialization boundaries: When code deserializes JSON (json.loads, JSON.parse, API responses), Dict[str, Any] / Record<string, any> is the correct type until schema validation narrows it. Do not flag dynamic types at JSON I/O boundaries when the schema is defined elsewhere (Pydantic model, TypedDict, Zod schema).
  • Large single-responsibility files: A file that implements one cohesive loader/parser/handler (single class, one public entry point) does not violate SRP even if it is >300 lines. Only flag STRUCT-007 when a file handles multiple unrelated concerns.
  • Async nesting: async/await with try/except adds inherent nesting depth. If nesting is <=4 and follows a standard async error-handling pattern, do not flag it as excessive.
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. 2d ago First seen · 49 lines · 62 tokens per session scan A 7842851d703a

Subscribe to this mod's changes

Judge Code Structure is an agent published in the GitHub repository KevinRabun/judges (7 stars, last pushed 2mo ago), licensed MIT. It adds 62 tokens to every session and 757 once invoked, about $0.0003 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