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 commands/cognitx-leyton/codegraph/dead-codegit clone --depth 1 https://github.com/cognitx-leyton/codegraphWhat 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.00019 | $0.00968 |
| Opus 5 | $0.00010 | $0.00484 |
| Sonnet 5 | $0.00004 | $0.00194 |
| Haiku 4.5 | $0.00002 | $0.00097 |
Grade A, and why
dead-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 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.
How it starts
The opening of the file, as written. The whole thing — 69 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Usage
/dead-code [path_prefix]
Scope defaults to codegraph/codegraph/ if no prefix is given. Pass any string that matches a :File.path prefix to scope elsewhere (e.g. packages/twenty-server/src/engine/).
Returns four categories of orphan, each tagged with a kind column so you can scan them together:
| Kind | What it means |
|---|---|
orphan_function |
:Function with no incoming CALLS / RENDERS and no outgoing DECORATED_BY (i.e. not a Typer / MCP / pytest entry point) |
orphan_class |
:Class with no incoming EXTENDS, INJECTS, RESOLVES, or IMPORTS_SYMBOL |
orphan_atom |
:Atom with no READS_ATOM or WRITES_ATOM consumers (React state defined but never used) |
orphan_endpoint |
:Endpoint with no HANDLES method (route declared but unhooked) |
What this does
PREFIX="${ARGUMENTS:-codegraph/codegraph/}"
codegraph query "
MATCH (f:Function)
WHERE f.file STARTS WITH '$PREFIX'
AND NOT EXISTS { ()-[:CALLS]->(f) }
AND NOT EXISTS { ()-[:RENDERS]->(f) }
AND NOT EXISTS { (f)-[:DECORATED_BY]->(:Decorator) }
RETURN 'orphan_function' AS kind, f.name AS name, f.file AS file
UNION ALL
MATCH (c:Class)
WHERE c.file STARTS WITH '$PREFIX'
AND NOT EXISTS { ()-[:EXTENDS]->(c) }
AND NOT EXISTS { ()-[:INJECTS]->(c) }
AND NOT EXISTS { ()-[:RESOLVES]->(c) }
AND NOT EXISTS { (:File)-[:IMPORTS_SYMBOL {symbol: c.name}]->(:File) }
RETURN 'orphan_class' AS kind, c.name AS name, c.file AS file
UNION ALL
MATCH (a:Atom)
WHERE a.file STARTS WITH '$PREFIX'
AND NOT EXISTS { ()-[:READS_ATOM]->(a) }
AND NOT EXISTS { ()-[:WRITES_ATOM]->(a) }
RETURN 'orphan_atom' AS kind, a.name AS name, a.file AS file
UNION ALL
MATCH (e:Endpoint)
WHERE e.file STARTS WITH '$PREFIX'
AND NOT EXISTS { (:Method)-[:HANDLES]->(e) }
RETURN 'orphan_endpoint' AS kind, (e.method + ' ' + e.path) AS name, e.file AS file
ORDER BY kind, file, name
LIMIT 100
"
Caveats
- Decorator exclusion is load-bearing. Without the
DECORATED_BYfilter, every@mcp.tool(),@app.command(),@pytest.fixture,@staticmethodfunction shows up as "orphan" because framework dispatchers invoke them via reflection. Keep the filter even if it occasionally hides a genuinely-dead decorated function. - Python module-level callers aren't tracked. The Python parser doesn't emit
CALLSfrom top-level code (Stage 1 limitation — resolver's Phase 4 requires a method-scoped caller). So a Python function called only from module-levelif __name__ == "__main__":blocks will appear as orphan. Spot-check before deleting. - Interface / Protocol implementations. A class that only "satisfies" a duck-typed protocol (no
EXTENDSedge, no explicit import) will show asorphan_class. For abstract-base-class compliance, use/graph "MATCH (c:Class {name:'Foo'})-[:EXTENDS]->(p:Class) RETURN p"to double-check. - 100-row limit. Raise it for exhaustive cleanup passes.
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.
- yesterday First seen · 69 lines · 19 tokens per session scan A 94fac24ff205
dead-code is a command published in the GitHub repository cognitx-leyton/codegraph (11 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 19 tokens to every session and 968 once invoked, about $0.0001 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 commands, from other repositories
feedback
Security Design Review — PRD/기획서 기반 보안 의견서·검토 의견서 생성.
compliance
이전 보안 진단 보고서의 Finding들이 패치되었는지 확인하고, 변경된 코드에서 신규 취약점을 탐색합니다.
va
Vulnerability Assessment — 8차원 아키텍처 진단 + Self-Verify + Evidence Verification.
pentest
Penetration Testing — 시나리오 기반 모의해킹 + POC + 라이브 검증 (State Delta 기반).
redteam
Red Team Operations — 인프라 설정 보안 리뷰 + MITRE ATT&CK + Detection Engineering.
verify
Adversarial Verification — 보안 진단 보고서 독립 검증 (Autonomous First).