xray-codebase
Skill3 starsChanged 40 days agoMITView on GitHub
X-ray a codebase or one area of it and return a visual HTML report of architecture friction and proposed improvements from proven patterns, such as explicit state machines, ports and adapters, and deep modules. Use for architecture reviews, refactoring direction, or finding why an area keeps breaking. Read-only; stops before planning.
In this repository13 other files it gives its agents.
- deliver-changeSkill
- diagnose-issueSkill
- explain-changeSkill
- implement-changeSkill
- merge-changeSkill
- plan-changeSkill
- publish-changeSkill
- remediate-findingsSkill
- respond-to-reviewSkill
- review-changeSkill
- review-prSkill
- setup-projectSkill
- verify-changeSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 6 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Read governing instructions, architecture docs, glossary, and ADRs.
- Very specific: line 51
Read each hot spot's code, its tests, and the fix commits that touched it.
- Distinctive: line 88
test impact: tests to add, tests that become simpler, and tests that break.
- Distinctive: line 97
Checkpoint 4: every candidate has every field above, and the top recommendation is named with its first safe step.
- Distinctive: line 102
Write the page with the visual report rules.
- Distinctive: line 120
Terminus: Leave alone, one row per area whose structure works with its evidence, and the unknown box with the Gaps.
- Distinctive: line 123
Run the render check.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
X-ray codebase
Find where the structure of the code makes change expensive or error-prone, and propose proven patterns that remove that friction. Each proposal carries the evidence and tradeoffs a team needs to decide. First read the contract core, the visual report rules, and the pattern catalog.
1. Scope and limits
- Identify the area and concern the user names. No area → the whole repository, ranked by hot spots. Record the repository and revision.
- Read governing instructions, architecture docs, glossary, and ADRs. An accepted decision constrains proposals: a proposal that contradicts one names it and states why it should be reopened. Use the project's terms in the report.
- The X-ray is read-only. Leave project files, branches, and the index unchanged. Probes go to scratch. Running existing tests is permitted; edits, plans in tracked files, and issues each need explicit authority.
Checkpoint 1: the scope, the revision, the governing decisions, and the permitted actions are stated.
2. Find hot spots
Combine signals; one signal alone ranks nothing:
- Churn: commits per file over the last 12 months, from
git log --since=12.months --name-only --format=. - Fix history: commits whose subject marks a fix, per file.
- Co-change: files that change together in the same commits across module boundaries.
- Size and coupling: file length, function length, and import fan-in and fan-out.
A hot spot is a file or module high on churn or fixes and high on size or coupling. Shallow history (fewer than 20 commits in scope) → rank by size, coupling, and the user's direction, and state the limit as a Gap.
Map the modules in scope and their dependencies. Mark the hot spots on that map.
Checkpoint 2: the top hot spots have their numbers, and the module map exists.
3. Diagnose friction
Read each hot spot's code, its tests, and the fix commits that touched it. Name
the friction in one line with file:line evidence. Friction is a structural cause
that repeats, such as:
- one concept scattered across several files that must change together;
- the same condition or flag combination checked in several places;
- illegal states the data types allow, guarded by scattered checks;
- I/O mixed into domain rules, so tests need the network, clock, or database;
- a shallow module whose interface is as complex as its body;
- an external model or format leaking through the codebase.
Apply the deletion test to each suspect module: remove it in thought and see where its complexity goes. Complexity that spreads to callers marks a module worth keeping or deepening; complexity that vanishes marks a pass-through.
Record good structure too: areas with low churn and clear boundaries. The report lists them as areas to leave alone.
Checkpoint 3: each friction has a file:line, the commits or co-change data
behind it, and the cost it causes.
4. Match patterns
For each friction, pick the catalog pattern whose signs match and whose when-not conditions do not. Compare it with doing nothing and with one smaller alternative. A friction with no matching pattern stays in the report as a problem without a proposal.
Record for each proposal:
- files and evidence:
file:line, churn, fix commits; - the problem in the project's terms;
- the pattern and its source;
- the move in one line; the top recommendation also gets an after diagram;
- tradeoffs and the alternatives considered;
- a migration outline in small, separately shippable steps, with the first safe step;
- test impact: tests to add, tests that become simpler, and tests that break;
- risk level and its basis;
- strength: Strong (evidence at several sites and a clear payoff), Worth exploring (evidence at one site or an uncertain payoff), or Speculative (inferred from structure alone).
Rank candidates by friction removed against migration cost and risk. Pick one top recommendation.
Checkpoint 4: every candidate has every field above, and the top recommendation is named with its first safe step.
5. Build the report
Write the page with the visual report rules. Sections, in this order:
- Header. The title names the top recommendation. The lede gives its strength and its first safe step.
- Decision board. The candidates as numbered questions, ranked, with the grid placing each one by value and cost.
- Module map. One diagram of the modules in scope with hot spots
highlighted, at most 10 nodes. Under it, the hot-spot table: churn, fixes,
size, and coupling. Choose the map's type from
Diagrams:
flowchart LRfor module dependencies,architecture-betawhen services and stores matter. Add atreemap-betaof size or a monthly churnxychartonly when it explains why a hot spot ranks high. - Candidate route. One stop per candidate, ranked. Each stop holds its chips
(files, strength, churn), its points (problem, pattern and source, the move),
and its question. The top recommendation's stop holds a before/after pair
(
stateDiagram-v2for a state machine). Details hold tradeoffs and alternatives, the migration outline, and test impact. - Terminus. Leave alone, one row per area whose structure works with its evidence, and the unknown box with the Gaps.
Run the render check.
Checkpoint 5: the page holds all five sections, every candidate stop carries an evidence tag and every proposal field, and the render check passed or is reported as unverified.
6. Report and stop
Return:
Report: absolute path | render check result
Scope: area | revision | history window
Top recommendation: pattern | files | strength | first safe step
Other candidates: pattern | strength, one per line
Gaps:Done when the report exists at the reported path and every candidate has evidence, tradeoffs, a migration outline, and a strength. The X-ray changes no project files. Adopting a candidate continues through plan-change, with the candidate's stop as its input.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

