Code intelligence

From event4u-app/agent-config · View interactive version

Code intelligence is an AI agent skill from the GitHub repository event4u-app/agent-config. Route codebase-structure questions (who calls X, where used, change-impact) to an existing code-graph first; cheaper, not better. Graph-first classes: none; grep routine. Also 'call graph'.

How to use this skill

Skill file

code-intelligence

For a structure question — who calls X, where is Y used, *what

imports Z, what breaks if I change this symbol* — ask an index that already

exists before rebuilding the relationship by hand: it is already built, its

answer is structured, and it costs a fraction of the tokens. It is not more

precise than a blind grep — measured on this repository and on two

third-party PHP subjects, zero classes met the win bar (§ Measured twice, § v3)

— so grep is the arm you fall back to routinely and with a stated reason, not grudgingly. This skill routes

such questions to the native code-graph engine (ADR-124, Class A) or a

consumer-shipped index first. It is the executable side of

CODE0:

orchestrator first, owner where it wins.

When to use

callers/callees, references, imports, inheritance, change-impact.

import graph by hand.

When NOT to use: content/semantic questions ("what does this function

mean", "find the string 'password'"), single-file edits, or a repo with no

code-graph and no appetite to build one — plain grep/read is right there.

Procedure

  1. **Orient first, when the question is "where does X live" rather than "who

calls X".** If agents/map/MAP.md exists, read it: it names the project's <!-- ref-ignore -->

areas (files grouped by coupling), its infrastructure files and its cycles.

No map yet? agent-config code-graph map builds one in seconds. Then query.

  1. Detect the source. agent-config code-graph detect — is a fresh consumer

graph.json or native cache present? (A consumer-shipped fresh index wins;

the native engine covers stale-or-absent — ADR-124 § 2.)

  1. Build if absent and worthwhile. No graph + PHP, TS/JS, Python, Go, Java

or C#? agent-config code-graph build (deterministic, LLM-free, ~seconds).

Unsupported stack, one-off ask — grep.

  1. Query. Pick the verb:

references it (the "impact of changing X" question). --since <ref>

seeds from a git diff.

Pass --budget <tokens> to cap output.

  1. Read the confidence. EXTRACTED = syntactic fact — a symbol declared in

the file, or a name bound to the module specifier the file names; INFERRED

= resolved by hierarchy, or by a repo-wide same-name lookup with no binding

in the file to justify it; AMBIGUOUS = dynamic dispatch / facade, carries

candidates — treat its target as one of the candidates, never as certain.

Two target shapes are not nodes and resolve to nothing you can read:

symbol:<name> (a name this repository does not declare) and

external:<module> / external:<module>#<name> (a name imported from

outside the indexed root — external:node:path).

  1. Fall back honestly. If the graph has no entry for the symbol, grep — and

say so: "the graph has no entry for X, so I grepped." If this command is

not available, grep and say so.

Output

Every answer built with this skill MUST:

— so the reader knows the provenance and freshness of the relationship claim.

present an AMBIGUOUS edge as a definite call; list its candidates or say

"ambiguous (dynamic dispatch)".

Gotcha

without one, missing routes mean "not covered", not "none".

behind, rebuild (agent-config code-graph build --update) before trusting

relationship answers, or say the answer is from a stale index.

ambiguous ABOUT.** A $obj->m() whose name matches a method declared

somewhere in the repo is AMBIGUOUS and carries those candidates: honest,

not broken — never "resolve" them by guessing. A

dynamic call whose name matches no in-repo method (xs.push(),

map.get()) is not emitted at all, and the count is published as

suppressed_edge_counts.dynamic_no_candidate. It used to be 39 % of this

engine's own graph, pointing at symbol:push — no node, unreachable by any

query verb.

2026-09-04 over the three roots the v2 benchmark uses: AMBIGUOUS is 0 of 495

edges under the graph-engine root, 0 of 181 under src/shared, and 121 of

4,002 (3.0 %) under its council root — class-free TypeScript has

few in-repo methods to confuse. A Laravel codebase (facades,

injected services dispatching onto in-repo methods) is the opposite. Read the

graph's counts, not a remembered ratio.

Measured twice, and it has not won (v2, 2026-08-29)

Pre-registered, published whichever way it landed:

internal/bench/reports/code-graph-vs-grep-inrepo-v2-2026-08-29.md. The native

engine scored against disciplined git grep over three in-repo TypeScript

roots, 19 questions, per-class bars fixed before the run and unchanged from v1.

| Class | grep R | graph R | Δ pp | grep P | graph P | verdict |

|---|---|---|---|---|---|---|

| callers | 1.000 | 1.000 | +0.0 | 0.611 | 0.667 | TIE |

| transitive-impact | 0.611 | 0.500 | −11.1 | 1.000 | 0.667 | NULL |

| path-between | 0.917 | 1.000 | +8.3 | 0.778 | 1.000 | TIE |

| references | 1.000 | 0.333 | −66.7 | 0.833 | 0.333 | NULL |

Zero classes met the win bar. On path-between the graph is exact and is the

only class where it out-precises grep; it still ties, because the delta is +8.3 pp

against a +10 pp bar that was fixed before the run.

The v1 run of 2026-08-28 published a false root cause, corrected 2026-08-29.

It reported path-between as VOID because "both arms measured nothing". Only

the grep arm did. The graph answered all three questions and v1's scorer discarded

the answer — it compared each returned symbol against the whole probe string

"cmdBuild -> getParser". v1 also never invoked the shipped path <a> <b> verb,

and counted unresolved symbol: pseudo-nodes as files, which is the sole reason

its callers verdict was NULL with recall tied. v1's numbers are not retro-edited

— they were faithful to v1's own registration — and v1's report now carries the

correction. Do not quote a path-between delta near +89 pp: that figure comes

from repairing the graph arm and leaving grep on the broken probe.

The rule's own wording was corrected by this result. external-code-graph-interop

used to open by saying a committed index answers "far more precisely than a fresh

grep". That was never measured, and when it was, it was false for the native

engine on this repository's own code. The rule now gives the reasons that survive

measurement — an index that exists is already built and structured, so it is the

cheap first question — and drops the precision claim its own benchmark refuted.

Re-run after the extractor repair (2026-09-04) — still no class won

internal/bench/reports/code-graph-vs-grep-inrepo-v2-rerun-2026-09-04.md. The

SAME registration, the same corpus SHA, the same per-class bars and the same

arm-B verbs, re-run after the import-binding repair. The 2026-08-29 report is

untouched; this is a second report beside it, which is how v1 was handled too.

| Class | graph R then | graph R now | graph P then | graph P now | verdict then → now |

|---|---|---|---|---|---|

| callers | 1.000 | 1.000 | 0.667 | 0.667 | TIE → TIE |

| transitive-impact | 0.500 | 0.611 | 0.667 | 1.000 | NULL → TIE |

| path-between | 1.000 | 1.000 | 1.000 | 1.000 | TIE → TIE |

| references | 0.333 | 1.000 | 0.333 | 1.000 | NULL → TIE |

Zero classes met the win bar, again. Two NULLs became TIEs and nothing

regressed, so the routing verdict below is unchanged — a TIE is not a win, and

no bar was renegotiated after the repair.

Root-drift caveats: that report (neither verdict change sat on a drifted root).

No class is graph-first. Query the index first because an index that already

exists is cheap to ask and its answer is structured — not because it answers

better. When it returns nothing, that is the common case, and grep remains the

arm to fall back to rather than a grudging afterthought.

A withdrawn sentence here called grep "the arm that won every valid class". The

defensible statement is "zero classes met the pre-registered win criterion", not that

grep proved superior.

Scope, stated so this table is not over-read: it measured the native engine

on this repository's TypeScript, with a corpus of 19 questions. It is not

comparable to the 2026-07-28 external-corpus run, it is not comparable to v1

either (corpus, arm-B verb set and scorer all moved), and it says nothing about a

consumer-shipped SCIP index. Literal-string probes are reported as a separate

capability-boundary class with no floor derived from them: a symbol index

cannot answer them at all, which is where grep stays necessary rather than a

defect in the engine.

v3, third-party subjects (2026-11-05) — no class won

internal/bench/reports/code-graph-v3-2026-11-05-scored.md; same bar, mostly PHP.

| Class | grep P / R | native P / R | Verdict |

|---|---|---|---|

| precise-semantics | .665 / .813 | .519 / .362 | NULL |

| route-trace | .106 / .861 | .464 / .248 | TIE |

| model-table | .083 / .361 | .917 / .361 | TIE |

| tests-for | .200 / .059 | .200 / .012 | TIE |

| change-impact | .792 / .138 | .353 / .322 | NULL |

| change-impact-xplane | 0 / 0 | 0 / 0 | TIE |

Class list: graph-first none, grep-routine all six. The engine is more precise on

routes and models, recalls less. Truth model-checked; suite F not run.

Staleness delivery — which hosts get it for free, and which do not

Migrated verbatim from external-code-graph-interop so the obligation stays in

the rule and the per-host delivery detail is paid only on activation.

On a host with a verified pre_tool_use contract, the code-graph-context

concern supplies this for free: once per session, on the first search or

code read, it delivers the graph's state as structured additionalContext —

code-graph: fresh or code-graph: N commit(s) behind. It is silent when no

graph exists, so hearing nothing is not evidence that the graph is fresh.

On every other host that carrier does not exist, and this section is the

delivery: run agent-config code-graph detect --format json before trusting a

relationship answer, and say which state you got. Which hosts those are is

agent-config hooks:status — resolved from the platform table, never guessed

from the host's name.

Either way the disposition is the same: behind:N → `agent-config code-graph

refresh` first, or use grep and say so. This is a freshness obligation, not an

ordering claim; the rule's query-first ordering still governs which source to

reach for.

The four gate verbs — a diff, not a symbol (2026-09-08)

query / affected / path / explain answer a question about a SYMBOL.

Four more answer a question about a DIFF, and they are documented here rather

than in § Procedure for a mechanical reason worth stating: step 4.3 of

road-to-a-graph-that-is-shipped verifies that this file's line 164 — the

No class is graph-first sentence — is unchanged, and inserting anything

above it moves that line. So the ordering claim K5 protects stays byte-fixed

and the new material sits below it.

Each of the four walks only edges whose resolution mechanism is a stated fact

(never a repo-wide same-name guess, never an untyped receiver), and each prints

the mechanisms it accepted, the mechanisms it refused, and the graph's

staleness — so a narrow answer is distinguishable from a decoupled one:

files reachable from the changed symbols, plus the producing edges and a

minimal read set.

An empty list is a finding, not an error.

file imports.

symbols with no accepted reference that no declared entry point names. It

refuses rather than answering while an entry-point source cannot be read:

this engine records no exportedness, so without a supplied list an

exported-but-unimported symbol is indistinguishable from a dead one, and a

confident false "dead" invites a deletion the graph cannot justify. Nothing it

lists is a deletion recommendation.

These answers reach an agent over MCP without shelling out, and the mapping is

not one tool per verb:

| MCP tool | answers |

|---|---|

| graph_impact | impact --diff as answer + budget, long lists {first,total}, test_files/seeds whole; untested_only: true → untested |

| graph_tests_for | tests-for; empty adds no_entry |

| graph_dead | dead |

| graph_query | query |

| graph_path | path |

| graph_node | no CLI verb — one symbol's location, in-edges, out-edges and degree |

| graph_map_status | agents/map/ freshness, health; file adds blast | <!-- ref-ignore -->

| graph_area | one area of the map: files, hubs, what it depends on |

| graph_estate | estate — across registered projects, from the local index (opt-in: projects index on) |

Every other tool takes project (a registered repo id, name or path).

untested is a flag on graph_impact: same question, same diff.

graph_impact is the only one that is not

read-only — it runs git diff --name-only to resolve its rev — and

graph_dead's refusal arrives as status: "refused", never as status: "ok"

with an empty list.

graph_node is the one entry with no CLI verb behind it, and the one that

REFUSES a seed it cannot resolve exactly. Every other reader answers about a

neighbourhood or a set, where a best-guess seed costs the caller one wrong line

among several; a node view's every field — the location, the degree, both edge

lists — is a statement about ONE node, so a guess is wrong in all of them at

once. It resolves on the exact tiers of the same seed ladder (node id, then

label) and returns status: "refused" naming the candidates when a label is

ambiguous, rather than scoring free text — which is the retrieval class the

measured null covers (docs/CLAIMS.md, code-graph-retrieval-null). Use

graph_query when a best-guess match is what you want.

No ordering claim is added here, and no measurement claim either. These

verbs are cheaper than reconstructing the same relationship by hand — that is a

claim about the ALTERNATIVE being a manual reconstruction, not about grep.

Nothing on this page says they beat grep, none of the four appears in the v2

benchmark corpus (which measures callers, transitive-impact, path-between

and references), and § Measured twice still governs that question.

Systems, provenance, domains, branches

Why installed, since when, which domain, on which branch.

Do NOT

courtesy).

a gate.

review-risk checks and recommended_reads as lists.

confirm a fact first.

See also

the rule that routes structure questions here.

discipline; the graph is one evidence source, still confirmed against the real

code when load-bearing.

artifact relation-graph (affected/explain). The external code-graph is the

source-code analogue; keep the two apart when answering.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.