AI Readiness Assessment + Complexity Hotspot
Three artefacts in one pass against a target repo:
- Practice assessment - a deterministic headline (the autonomy Step, the gate that blocks the next one, "Catalogue coverage: N of M measured" and the per-tag strip) over per-practice verdicts across navigability, runtime liveness, code design, linters, architecture tests, CI, coverage, review bots, and AI project management.
- Complexity hotspot SVG - Codecov-style treemap of the code. Size = LOC. Colour = cyclomatic complexity. Saturation = recent git churn. Vivid red = complex AND active = riskiest to change.
- Doc navigability SVG - a node-graph of the docs. Structure = connectivity (centre = entry, rim = unreachable, dashed ring = orphan, solid edge = link, dotted edge = reference); colour = staleness (vivid red = a frozen doc beside churning code = a lying map); size = file length. Folds navigability and the decaying-map signal into one artifact.
Both SVGs are colour-blind-safe by default (OrRd ramp, no red-green).
All land as files inside the target repo. The skill always writes them locally; after writing, ask the user whether to open a PR in the target repo with the artefacts.
The model: truth-pressure, not presence
Read this before scoring - it changes how you score. Across every layer, the real signal is never presence. It is whether a thing is under active pressure to stay true:
- Tests keep behaviour honest (CI fails when it's wrong).
- Retros / feedback loops keep the process honest (Layer 8 scores whether retros are carried out, not merely present).
- Maintenance keeps docs honest (a wiki tracked against code churn).
- Telemetry / liveness keeps relevance honest (is this code actually exercised).
So AI-readiness is the degree to which a codebase's self-descriptions are kept honest, not the degree to which scaffolding exists. Score artefacts on maintenance pressure, not existence. A stale-but-present doc scores at or below absent: missing makes the agent go look; confidently-stale makes it navigate fast to a wrong, current-looking conclusion.
The 9 layers (0-8) fall into three bands, ordered by dependency - what must hold for the next band to mean anything:
- Read-side foundation (L0 navigability, L1 liveness) - can the agent form a true picture before it acts?
- Write-side enforcement (L2-L7) - can the agent be trusted to produce good output? Only means something once you can trust that what you're reading is real and current.
- Meta (L8 feedback) - does the system keep itself honest over time? Depends on a working enforced system to improve, so it stays last.
The three write-side tendencies the layers guard against
The write-side scores aren't abstract good practice - each traces to a known tendency of an AI contributor, observed across models. All three are the same defect: a self-description (the file's shape, a comment's promise, a gate's verdict) under no pressure to stay true. The deterministic core turns each into a cross-practice finding so the report names the specific files, not just the category:
- Accretion - an agent does what is asked, and what is asked is feature after feature; nothing in that loop asks for a refactor, so files only grow. Now fully instrumented via the
accretion_ratchetfinding: a file whose accumulated line count ratcheted monotonically upward across multiple commits with almost no deletion pressure (deletions below ~15% of total churn). Only top complexity/size-band files are flagged, never documentation, so growth-but-simple is never noise;archive/,archived/andattic/paths stay out of the attention list, disclosed inexcluded_as_archive. It surfaces on three surfaces - theaccretion_ratchetblock inrun-context.json, theaccretion_ratchetcross-practice finding (with its files in the attention list), and a growth-profile line on each flagged hotspot page (hotspots/*.md). The signal disclaims itself (rather than dropping the result) when the git history is degenerate - a shallow clone or squashed import has no meaningful net-delta sequence, so the block carriesreliable: falseand the hotspot line is marked as possibly incomplete. - Unactioned intent - an agent records promises it never returns to keep (
TODO/FIXME/ "remove after migration"). Instrumented via theunactioned_intentfinding: markers aged by the edits they survived without being kept - a lying map of intent. - Guardrail erosion - under pressure to make red go green, an agent loosens the check instead of fixing the root (a suppression, a skipped test, a widened threshold), hollowing out the layers meant to protect it while they still read as Present.
Repository archetype (not every repo is software)
The layered model assumes a software repo. A knowledge / document base - markdown sources, an LLM-maintained wiki, a CLAUDE.md schema, and no application code or runtime - has no code surface for the write-side layers (L2-L7). Marking them Missing is itself a lying verdict: a well-run KB reads as mostly missing when it is in fact well-run, with gaps reported for tests on code it doesn't contain.
The deterministic core (lib/keyhole/archetype.py) classifies the repo and writes an archetype block to run-context.json:
- Detection is a heuristic - the code-file ratio (code vs markdown) and the absence of a runtime surface (
package.json,pyproject.toml,go.mod,Dockerfile, ...). A documentation-heavy application (lots of markdown but a real build) stays software because of the runtime-surface gate. - Override marker. An
assess-archetype: knowledge-base(orsoftware) marker in any instruction file (CLAUDE.md/AGENTS.md/...) forces or suppresses detection, so a maintainer is never trapped by a misfire. Write it as an HTML comment, e.g.<!-- assess-archetype: knowledge-base -->. - Scoring. For a detected knowledge base the write-side layers (2-7) are marked N/A (not Missing) in the scorecard, so they name no gap; the applicable layers (L0, L1, L8) get verdicts on their merits. The headline is unchanged by the archetype: it reads the maturity model's conditions, not layers. A software repo gets a verdict for every layer 0-8.
- KB-maintenance signal.
archetype.kb_maintenanceflags whether the repo documents how the AI maintains the KB - the Karpathy LLM-wiki pattern (immutable raw sources, the schema file as the product, an ingest workflow, query-as-filing, periodic lint/consolidation). It is both a detection signal and a scored read-side (Layer 0) quality signal; the gist is cited in the report as the best-practice pointer whether or not the workflow is documented.
This is intentionally one archetype (knowledge base), structured as an extensible dispatch so more are cheap to add later - not a general archetype framework (YAGNI). The assess-layer-scorer agent reads the block (its Step 0) and the assess-findings skill renders N/A layers in the scorecard.
<!-- chat-replace:tour-arguments -->
Arguments: $ARGUMENTS. --tour (the guided first run): when the arguments contain --tour, skip every step below. Do not assess the current repository. Follow references/tour.md (relative to this skill dir) instead: it builds a small sample repository in a temporary directory, walks the report one section at a time, has the newcomer make one fix and re-runs so they see the Step move.
Step 1: Determine Repo Root and Output Directory
git rev-parse --show-toplevel # from the arg path if given, else pwd
Set $REPO_ROOT to the result. All scanning happens from here. --fix and --starter (#1154) are the only arguments that write starter files into the target (/fleet never does): when the arguments contain either, follow references/fix.md (relative to this skill dir); they commit to a local assess/fix-<gate> branch and never push, and only an added --pr, which an interactive run asks the user about first, pushes and opens a pull request.
Scoping a subtree (/assess <path>). When the argument is a directory under the repo root, scope the whole run to it - metrics, score, badge, wiki, and gate all computed for and labelled with the scope, artifacts under .assess/<scope-slug>/, no signal from a sibling. Pass --scope "$SCOPE" to complexity-treemap.py, assess_core.py and assess_finalize.py and swap .assess/ for .assess/<slug>/ throughout. Full recipe: references/monorepo-scoping.md (relative to this skill dir). A no-path run is whole-repo, unchanged. Choosing the bar. The run scores against the default maturity model (levels/default.toml) unless the user names another. --profile handover is the bar a production team expects before it takes a repository over; --profile citizen is the lighter bar while a citizen developer builds; each profile file (levels/profiles/<name>.toml) says why it holds each practice. --levels FILE takes a custom maturity model, as /fleet --levels does, and gives the same Step for the same repository. Pass the same flag to assess_core.py and to --opt-in-mutation. A profile or --levels run runs only the scans its model reads, plus those the headline needs, so it is quicker; every other block in run-context.json reads not run under profile <name> (the scan_plan block lists what ran and what did not), and the report says so in place of those sections. Never read such a block as zero or as unmet. Add --all-scans when the user wants the whole report under a profile. The executive summary then opens by naming the model and saying either "Ready for handover (profile: handover)" or exactly which practices are missing; practices the default model does not define are marked. Paste it as it stands. A profile or --levels run labels the badge and the log.md readiness line with the model (... (profile: handover)). A profile run keeps its own record in the committed .assess/prior-level.json beside the default model's, so "since last run" and the CI gate compare it with the last run of the same profile; a custom --levels run keeps none. When the user wants a practice of their own, scripts/levels_new.py "$REPO_ROOT/my-team.toml" --profile handover (the script is relative to this skill dir; run it with uv run, and write the copy into the user's repository, never the skill dir; leave out --profile to copy the default) writes a commented copy that loads with --levels; the toolkit's docs/build-your-own-practice.md walks through adding one.
Decide the output directory (default: $REPO_ROOT/.assess/). Create it if needed:
mkdir -p "$REPO_ROOT/.assess"
Artefacts will land at:
$REPO_ROOT/.assess/complexity-heatmap.svg$REPO_ROOT/.assess/complexity-stats.json$REPO_ROOT/.assess/doc-graph.svg$REPO_ROOT/.assess/step-ladder.svg(written by the deterministic core from the level result: the maturity model's Steps as rungs, bottom to top, each with what an agent can do there, the gate between each pair, "You are here" on the run's Step and the next gate highlighted; the report shows it first),$REPO_ROOT/.assess/evidence-waffle.svg(also by the deterministic core from the level result: one square per maturity-model condition, coloured by state and evidence grade, a "Level N" header per column and the Step-gate squares outlined) and$REPO_ROOT/.assess/tag-profile.svg(from the level result's per-tag rows: one row per truth tag with the share of its measured conditions met, the earlier run's share as a hollow dot whenprior-level.jsonholds the same maturity-model version)$REPO_ROOT/.assess/package-map.svg,$REPO_ROOT/.assess/doc-drift.svgand$REPO_ROOT/.assess/review-strip.svg(written by the deterministic core when their data is available: the 20 largest packages as an import matrix with front-door bypasses outlined, the docs furthest behind their code, and the review state of each sampled merged change)$REPO_ROOT/.assess/assess-report.md
Write-protected repo root?
/assesswrites.assess/into$REPO_ROOT, and the treemap/core run asuvsubprocesses that write there too. If your workflow keeps the repo root pristine and read-only (e.g. a<repo>-mainclone that teammates branch from, with a hook blocking direct edits), a guard on your writes won't stop the subprocess - it just makes the run write into the directory you meant to protect. Create a worktree first and run/assessfrom there.
Step 2: Generate the Code Heatmap + Doc Graph
This step produces two views of the codebase, both colour-blind-safe (OrRd ramp, no red-green):
- Complexity heatmap (
complexity-heatmap.svg) - a treemap of the code. Size = LOC, colour = cyclomatic complexity, saturation = recent churn. Vivid red = complex AND active = "hard to change safely". - Doc navigability graph (
doc-graph.svg) - a node-graph of the docs. Structure shows connectivity (centre = entry point, rings = link-distance, rim = unreachable; orphans carry a dashed ring; solid edges are links, dotted edges references); colour shows staleness in the same grammar as the code heatmap (vivid red = a frozen doc beside churning code = a lying map); size = file length. It folds both Layer 0 doc signals - navigability and the decaying-map - into one artifact. Beyond static wikilinks and CommonMark links, it counts a backticked path to an existing doc as a reference edge (a cited.claude/file included) and recognises Obsidian vault-native navigation -.baseview hubs anddataviewquery blocks - as edges (resolved statically by folder / tag / frontmatter predicate), so a vault navigated by dynamic queries isn't mis-scored as orphaned. The SVG and the scored signal compute over the identical doc set: both honour the same excludes (.assess/config.toml).
Feed the complexity stats into the linter/complexity layer (Layer 3) and the doc_graph / doc_staleness blocks of run-context.json into Layer 0 (the graph SVG is the visual; the score reads the structured blocks). The core also reads the repo's Claude Code configuration - .claude/skills/, .claude/commands/, .claude/agents/, and for a plugin repo skills/, commands/, agents/ or the paths .claude-plugin/plugin.json names - and writes the claude_config block: legacy command files, and frontmatter keys or values Claude Code silently ignores, checked against documented field sets pinned in scripts/lib/instructions/claude_config_fields.py with their snapshot date. It is Layer 0 evidence, not a badge finding; available: false (no .claude/ and no plugin manifest) means not checked, never clean. Beside it, the agent_harness block lists what the committed agent configuration runs on every session (settings and frontmatter hooks, env names, apiKeyHelper, .mcp.json, .cursor/hooks.json) and flags a tracked .env or settings.local.json, a missing .env deny rule, disableAllHooks: false, a broad Bash allow, a devcontainer credential mount, hidden Unicode in instruction files and comment-triggered deploys; it is informational and never prints a secret value. The instruction_placement block splits each instruction file on its headings and names the sections that belong outside the always-loaded layer (line ranges, the signals that fired, a suggested home), with agent and SKILL.md files over 200 lines in a separate informational list. It is Layer 0 advice; the instruction grade is scored on the same split (always-on lines past 200, and lines that belong elsewhere), and the agent and skill list has no grade effect. The agent_environment block feeds Layer 5: committed agent setup (copilot-setup-steps.yml, a dev container, .cursor/environment.json, a SessionStart hook, a setup script or target), the check command an instruction file names, lockfiles per manifest, and layer5_cap; its ci_duration is the one gh read, optional and available: false with a reason when gh cannot answer. The ai_usage block is informational and scores no layer: the share of commits in the churn window (the --window in a headless run) with an AI-assistant Co-authored-by trailer, the share authored by an agent identity (pinned agent apps plus the [ai_usage] rules of .assess/config.toml or --fleet-config), and the share with either, each a lower bound on agent use (squash merges, missing trailers and unrecognised identities undercount), so report it as "at least", never as an estimate. Dependency bots and GitLab access-token users are counted apart, never as agents unless a configured rule says so. The agent_outcome block (#1085) is informational too and scores nothing: of the agent commits ai_usage counts (trailer or agent author), the share later reverted (a This reverts commit message naming it, or a later inverse diff) and the share with an added line rewritten within rework_days (14), with the counts and the window; a share with nothing to divide by is null with a reason, and a shallow clone makes the block unavailable. Bot and agent accounts (#765). Only unambiguous agent accounts (claude[bot], noreply@anthropic.com) and AI co-author trailers count unconfirmed; every other automated-looking account counts as nothing and is counted in ai_usage.identities_awaiting_confirmation. The human classifies them in a committed [identities] section of .assess/config.toml of literal e-mails or logins (agents = ["cursor@example.com"], bots = ["codecov[bot]", "renovate[bot]"], people = ["ann@example.com"]); a confirmed class beats every pinned agent rule (a dependency bot stays a dependency bot). The first-run discovery is uv run scripts/identity_candidates.py <repo> (terminal only, never prompts; --json; --confirm agent=ACCOUNT, bot= or person= writes the answer): after the core, list the candidates, ask the human in an interactive run, record the answers and re-run the core, following references/identities.md; a headless run never asks and the report states "N accounts awaiting confirmation" as a next step.
The consent lifecycle (read `references/consent-lifecycle.md`)
Steps 2a/2b/2d and the assess-pr end-of-run offers share one consent model, specified in full in references/consent-lifecycle.md (relative to this skill dir) - load it before running the offers. Essential hooks the steps rely on: decline markers carry provenance (write .no-<tool> JSON via the reference's write_decline_marker helper, never a bare touch; a mutation decline under an older plugin major sets reoffer_mutation: true so Step 2d re-asks once); three phases each a single batched question (Phase 1 tool installs 2a+2b, Phase 3 the separate mutation pass 2d, Phase 2 the assess-pr write-back offers); and the non-interactive contract - a headless/CI run makes no AskUserQuestion calls in any phase, Phase 1 as orchestration from your runtime context and Phases 2/3 from the core's run-context.json .interactive flag, which pre-records every skipped offer in .offers.