Skip to content

feat: the discovery walk as a Claude Code plugin (M23) - #53

Merged
jgrodziski merged 16 commits into
mainfrom
feat/m23-discover-skills
Nov 27, 2026
Merged

jgrodziski merged 16 commits into
mainfrom
feat/m23-discover-skills

Conversation

@jgrodziski

Copy link
Copy Markdown
Contributor

M23 (PLAN.md §24): the discovery walk as a Claude Code plugin, plus the CLI it needs. Given a repository, an agent walks a person through six questions in a fixed order: structure, boundaries, activity, stimuli and flows, meaning, domain. It runs each step's commands, shows a few rows at a time, keeps facts and inferences apart, and writes what it found to a hidden .codegraph/ workspace (listed in .git/info/exclude) so a walk stops and resumes.

What it adds

CLI

  • codegraph query <model> "SELECT …" runs one read-only statement over the store. The node and dep helper views are created on every run, and their single definition lives in @codegraph/analyzer. Parameters are bound (--param, --param-file). Output is a table, --csv, or --json (codegraph.queryResult/1). Read-only is enforced twice, by the handle and by a one-statement rule, so VACUUM INTO and a second statement are refused with exit 2.
  • history --report hotspots --model FILE [--rank classic|branchy|tangled|fragile] and history --report summary --model FILE join the git history with a model.

plugin/ — text and SQL, nothing executable, imported by nothing

  • Skills: discover (the guide: preflight, intake, resume, --tour), one skill per step (discover-1-structure … discover-6-domain), and query.
  • references/: rhythm, evidence, the state schema, the report, capabilities.md (generated from the profiles), and the stack tables for Spring, ASP.NET, NestJS, Phoenix and Rails.
  • queries/*.sql: the statements the discover pages show, held equal to the pages by a test.
  • Step 5 plans and prices explain for free and runs it only after an explicit yes for a stated scope, provider and ceiling. Step 6 hands over to Specy (its side is on specy-ai/skills main, 39e87b6).
  • evals/: four claude plugin eval cases.

Distribution

  • .claude-plugin/marketplace.json at the root. Installing takes two commands: /plugin marketplace add defsquare/codegraph, then /plugin install codegraph@codegraph.
  • plugin.json and the marketplace entry carry the root version, and a test enforces it.
  • The release step is in docs/distribution.md: validate, then claude plugin tag plugin --push (codegraph--vX.Y.Z, which doesn't match the v* release trigger).

Docs: a how-to (discover-with-claude-code), a line on each discover page naming its skill, query-model-db leading with codegraph query, the discover pages rewritten around the commands and their rows, README, CLAUDE.md, docs/cli.md, docs/sql-cookbook.md, and PLAN §24 with an "As built" block per milestone.

Before merging

  • The marketplace serves main. After this merges, the installable plugin needs a codegraph from the release after v0.4.0, because query and the joined hotspots aren't in v0.4.0. On an older binary the guide's preflight (codegraph query --views) says so and stops.
  • Eval scores are a smoke, not a measurement. One run per arm (§24.8): the step-5 gate and Ruby honesty pass with the plugin and fail without it (Δ +1 each). The bug-fix case passes in both arms; it only checks that the plugin stays out of the way. triggers-on-understand is 0: the guide fires, but the reply grader fails, twice. Three runs per arm and a tour with the installed plugin are owed before the release.
  • Python came with the rebase onto v0.4.0. It is in the capability sheet and the preflight, but there is no Python stack table, and Django, Flask and FastAPI are listed as not covered.

Verification

  • pnpm -r test green: CLI 1 891 tests, 533 of them in the plugin suites. The analyzer's scale.test.ts times out under a parallel run and passes alone, as M21 recorded.
  • Typecheck green; ESLint clean on everything this PR changes.
  • pnpm -r build green, the website included (it needs the Hextra submodule initialized).
  • The single-executable image passes every check in sea-smoke.mjs.
  • claude plugin validate . --strict passes.
  • test(cli): await the long e2e loops fixes a vitest worker-RPC timeout this branch introduced. Every test passed but the run exited 1: two exit-code tests spawned each case synchronously, blocking their worker for 9–14 s. The error appeared in 4 of 4 runs before the fix and 0 of 2 after; main was clean in 2 of 2.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PKCVh2Y278aB9F8ys12uiP

jgrodziski and others added 16 commits November 26, 2026 21:44
The node and dep views had three copies in the docs and none in the
code. They get one definition (store/helper-views.ts), created as TEMP
views in the connection that asks for them.

store/query.ts runs ONE read-only statement over a store: the handle is
read-only, and the text must be a single statement that begins with a
keyword that reads, because a read-only handle still executes VACUUM
INTO. Parameters are bound by name and checked both ways before the
statement runs: SQLite binds NULL to a parameter nobody gave, which
returns no row and reads as "there are none".

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2essA8PpHntfjvJtH
SQL over a model's store with the SQLite already in the binary, so an
ad-hoc question needs no sqlite3 on the machine:

  codegraph query app.jsonl "SELECT kind, count(*) FROM node GROUP BY 1"
  codegraph query app.jsonl --file reach.sql --param id=... --json
  codegraph query --views

Rows on stdout as a table, --json (codegraph.queryResult/1) or --csv,
cut at --limit (50) with the total on stderr. Every refusal is a usage
error (exit 2), SQLite's included; a file that is not a model is exit 3.

--param-file NAME=FILE binds a file's whole text, as text: one statement
reads the rows another saved with --json (json_each(:NAME, '$.rows')),
so a list of ids is never retyped on a command line.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2essA8PpHntfjvJtH
history --report hotspots --model FILE gives each changed file its
lines, its cyclomatic complexity, the size of its dependency cycle and
its rank in four families: classic (revisions x lines), branchy
(x cyclomatic, the default order), tangled (in a cycle), fragile
(x fix density). --rank chooses the order. A score of 0 is not ranked:
no measured operation is "not measured", never "simple".

Each row says who holds the file without a name: the main author's
share, that author's row in --report authors, the day last seen.

history --report summary --model FILE adds the share of commits that
cross a top-level directory of the model.

A --model with an invalid line loaded as an empty model, and hidden
then answered "none" with exit 0. It is now exit 3 for every report
that reads a model.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2essA8PpHntfjvJtH
docs/cli.md and the website's CLI reference gain query and the joined
history reports.

The discovery pages run their SQL as written, which they did not: a
view rendered a wrong id for an anonymous TypeScript function, three
queries named Java's kinds and found nothing elsewhere, a sum counted
a nested type twice, and printed tables were not their query's rows.
Step 3 loses its sqlite3-to-spreadsheet recipe for two commands. Step 4
is rewritten around an inventory of entry points from a table of names,
the chain behind each on facts and with candidates, and what nothing
reaches.

A test holds the three docs copies of the helper views equal to the
analyzer's definition.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2essA8PpHntfjvJtH
A Claude Code plugin, plugin/, versioned with the CLI it drives: text
and SQL, nothing executable.

- discover: the guide (preflight, intake, resume, --tour, routing)
- discover-1-structure … discover-4-stimuli: one skill per question
- query: a question in words as one saved SELECT
- references/: the rhythm of a step, how a finding is written, the
  state file and its schema, the report, what each language gives, the
  stack tables of step 4
- queries/: the statements the pages show, one per file

What a step learns goes to .codegraph/ in the analyzed repository,
hidden through .git/info/exclude; a session resumes from it alone.

The tests hold what no compiler does: every command line a skill writes
parses with the CLI's own specs, every query runs on the five fixtures
and equals an in-memory count, pages and query files hold the same SQL,
the state's findings are each page's "Write down" list.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2essA8PpHntfjvJtH
Section 24: the design, the decisions and their rejected alternatives,
the validation, the milestone split M23a-M23e, and what was built in
M23a, M23b and M23c with what measurement changed.

Sections 22 and 23 are M21's and M22's, on their own branches; the
milestones and decisions sections take the numbers they will have once
those land.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2essA8PpHntfjvJtH
tableCells is what --table prints for each cell, one number of decimals
per column; a test pins a page's printed rows to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2Y278aB9F8ys12uiP
- discover-5-meaning: the consent block, a scope proposed from steps 3
  and 4, the explain run in the background and its readings
- discover-6-domain: domain-facts, the three readings, the hand-over
  to Specy's extraction skills
- queries purity, chain-position, invariant-evidence
- references/consent.md; a complete example state file
- the state schema takes findings for steps 5 and 6, each with an
  origin: explain or session

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2Y278aB9F8ys12uiP
The pages run the commands step 5 and 6 run, with their rows; domain.md
loses its planned-change sentence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2Y278aB9F8ys12uiP
What the live gate measured: the metrics pass changes every explain
fingerprint, a scope of types has no module record, --safe-mode drops
--plugin-dir skills.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2Y278aB9F8ys12uiP
M22 reached main while the plugin was written. capabilities.md gains
Python's column (regenerated; it takes --trace), the preflight looks for
codegraph-python, and stacks.md lists Python's frameworks as not covered:
no Django, Flask or FastAPI table was checked on a corpus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2Y278aB9F8ys12uiP
- .claude-plugin/marketplace.json at the root: one plugin, ./plugin;
  /plugin marketplace add defsquare/codegraph, then
  /plugin install codegraph@codegraph
- plugin.json at 0.4.0, the root's version; a test holds the
  marketplace entry to it, as claude plugin tag will
- the plugin README's install lines; the release step in
  docs/distribution.md: validate, then claude plugin tag --push

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2Y278aB9F8ys12uiP
Four claude plugin eval cases, one per property of PLAN §24.8 a
session-free test cannot hold: the guide chosen to understand a codebase
and not for a bug fix, step 5 asking for a yes when told not to, step 2
saying Ruby has no wiring report. No Bash is granted: a case holds what
a skill decides and says, and runs without the OS sandbox.

The manifest test admits case.yaml, prompt.md, scaffold.sh and graders
under evals/ and nothing else; a run's results/ is ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2Y278aB9F8ys12uiP
- how-to/discover-with-claude-code: install, start, resume, what it
  writes and what it costs
- each discover page names its step's skill
- query-model-db leads with codegraph query; the views stay verbatim
  for other clients
- README, CLAUDE.md and docs/cli.md name the plugin and its boundary

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2Y278aB9F8ys12uiP
As built: the rebase onto v0.4.0, the marketplace, Python, the evals
without Bash, the release step. The smoke run's scores in §24.8: 3 of 4,
triggers-on-understand failing on its reply grader. Milestones M23a-e
marked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2Y278aB9F8ys12uiP
Two exit-code tests spawn every case in one loop. Synchronously, each
held its worker's event loop for 9 to 14 s once query's eleven cases
joined them, and vitest's worker RPC timed out behind it: every test
green, the run red. runCliAsync spawns without blocking; the loops await
it. Four full runs out of four showed the error before, two of two none
after; main showed none in two.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVh2Y278aB9F8ys12uiP
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
codegraph 78335ca Commit Preview URL

Branch Preview URL
Nov 26 2026, 10:57 PM

@jgrodziski
jgrodziski merged commit b059517 into main Nov 27, 2026
107 of 108 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant