/claude-engineering-skills:explainfrom Claude Engineering Skills
Explain WHY a piece of code is structured the way it is. Synthesises architectural-memory similar-symbols, git history (blame + commits + PR context), AGENTS.md/CLAUDE.md principles, and any plan documents that mention the target. Useful for onboarding ("why is this here?"), debugging ("why is X structured this way and not Y?"), and refactoring ("can I change this safely or is there hidden context?"). Pick by INPUT: a TOPIC to survey comes here ("have we touched rate limiting?"); a CLAIM to test goes to /investigate ("that landed in July" — it uses --history as one of its instruments). Invoke on the question's shape, don't pre-check the target exists first — Step 0 validates it and reports cleanly if missing; don't Grep/Glob and answer directly instead. Triggers on: "why is this", "explain this code", "why does this exist", "what is this for", "/explain", "give me context on". Full command syntax: see the Usage section in this skill.
Ships in Claude Engineering Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This skill's last line is an end marker naming the skill between em-dashes, after the Reference files table. If that last line is not in your context (context compaction keeps only the start of a skill), re-read
.claude/skills/explain/SKILL.mdin full before continuing — the later steps still apply.
Worktree preflight — in a linked git worktree the gitignored tooling tree
scripts/.claude-skills/is absent (git worktree adddoes not populate it), so every command below that uses it dies onMODULE_NOT_FOUND. Runnpm run skills:hydratefirst; if no such script exists,references/worktree-preflight.mdholds the entry to add (ask the user first: it editspackage.json). Keys are not copied: put them in~/.audit-loop.env, which every worktree reads.
Usage:
/explain <file> — Explain the file's purpose + history
/explain <file>:<line> — Explain a specific line/section
/explain <symbol-name> — Find + explain a function/class by name
/explain <file>:<line> --depth=full — Include full neighbourhood + all blame
/explain --history "<topic>" — "Did we already solve this?" — cross-source search
Multi-source synthesiser for "why is this here?" questions. Given a target (file, file:line, or symbol name), gathers context from four sources and produces one coherent explanation.
This skill does NOT modify code. Read-only — gathers + synthesises.
Input shapes:
| Input | Action |
|---|---|
<file> (e.g., scripts/openai-audit.mjs) | Whole-file mode — explain purpose + history |
<file>:<line> (e.g., scripts/openai-audit.mjs:412) | Section mode — explain the symbol containing that line |
<symbol-name> (e.g., runMultiPassCodeAudit) | Symbol mode — find the file:line via architectural-memory + Grep, then explain |
--history "<topic>" | History mode — "did we already solve this?" — jump to §History Mode below; skip Steps 1–5 |
Validate the file exists (file/section/symbol modes only). If symbol mode
<file>:<line>)."--history "<topic>"When the input is --history "<topic>" (e.g. /explain --history "rate limiting"),
the question is "have we touched this before?" rather than "why is this here?"
Skip the file-shaped Steps 1–5 and run the cross-source aggregator instead.
node scripts/explain-history.mjs --topic "rate limiting"
Optional flags: --since "GIT-SINCE-DATE", --paths "CSV-OF-PATHS", --limit N.
Add --skip-arch when the cloud is offline or when the user wants
faster local-only search.
The aggregator searches git log (three passes, incl. -G so moves are not
missed), architectural memory, plan documents and the brainstorm session ledger,
and returns one JSON document with per-source results plus a chronological
timeline. Render it as a Markdown digest: the helper's summary verbatim, a
most-recent-first timeline, then per-source tables — omit empty source-sections;
an empty timeline reads "No prior touches found — this appears to be new ground."
→ references/history-mode.md — read when running --history, for the source
detail, the exact digest template and how to read the result.
Output rules — same as §Output rules below: read-only, and every claim in the
digest maps to one of the four source sections. Cost: ~$0.0003 for the
arch-memory embedding (skipped when --skip-arch or cloud is offline); the other
three sources are local-only.
If cross-skill.mjs exists in the repo and Supabase is configured:
# 1. Near-duplicates and similar symbols
node scripts/cross-skill.mjs get-neighbourhood --json '{
"targetPaths": ["<file>"],
"intentDescription": "Understand the purpose and shape of <symbol-or-file>",
"k": 6
}'
# 2. Domain assignment (Plan v6 §2.4 — anchors the explanation in
# the architecture map's domain structure)
node scripts/cross-skill.mjs compute-target-domains --json '{
"targetPaths": ["<file>"]
}'
# 3. Caller domains (cross-domain reach detection — Plan v6 §2.4)
node scripts/cross-skill.mjs get-callers-for-file --json '{
"path": "<file>"
}'
Use the result to:
purposeSummary of the matching record)reuse, that's a signal this is the canonical version of a patterncompute-target-domains.domains[0]) — emit as **Domain**: \`` in the outputget-callers-for-file) — see deterministic spec belowLet homeDomain = compute-target-domains.domains[0] and callerDomains = get-callers-for-file.callerDomains. Trigger the "Cross-domain reach
detected" finding if and only if all of:
callerDomains.length > 0 (importers exist)nonSelfCallerDomains = callerDomains.filter(d => d !== homeDomain) has length > 0 (any external-domain caller is the leak)homeDomain is NOT null/"unknown" AND is NOT in the cross-cutting allowlist: ["shared-lib", "shared-frontend", "core", "utils", "scripts"] (Audit-Gemini-G4: untagged files would otherwise spam false-positive cross-domain warnings on every importer — skip the check entirely when the file's home domain is unknown)get-callers-for-file.snapshotProvenance === "import-graph-populated" (skip silently if "pre-feature-snapshot" / "no-active-snapshot" / "cloud-disabled" — false signal otherwise)When triggered, render exactly:
**Cross-domain reach detected**: `<homeDomain>` file called from
`<nonSelfCallerDomains[0]>`, `<nonSelfCallerDomains[1]>` (etc) — explain whether this is intentional shared API vs leaked internal.
Omit the section entirely when not triggered.
If Supabase is offline → skip all three subcommands and note
[arch-memory: unavailable] in the output.
FILE=scripts/lib/*.mjs # the file you're explaining
LINE=42 # the line, if one was specified — omit -L flags otherwise
# Who wrote it + when (last 5 lines of context if line is specified)
git blame -L $LINE,+5 "$FILE"
# When the file was created + changed (last 10 commits)
git log --oneline -10 -- "$FILE"
# Recent commits that touched the symbol (if line known)
# NOTE: use git's native +offset syntax — git does NOT evaluate "LINE+10"
# arithmetic in -L. Pass +10 directly so git computes line + 10 internally
# (Gemini-R1-G4 fix).
git log -L $LINE,+10:"$FILE" --oneline | head -10
# PR context (if gh CLI available)
LAST_COMMIT=$(git log -1 --format=%H -- "$FILE")
gh api "repos/{owner}/{repo}/commits/$LAST_COMMIT/pulls" --jq '.[].title' 2>/dev/null
Extract:
Search AGENTS.md, CLAUDE.md, and any docs/plans/*.md for mentions of:
grep -rn "<symbol-name>\|<file>" AGENTS.md CLAUDE.md docs/plans/ 2>/dev/null | head -20
Look specifically for:
Read the target file (or the symbol's enclosing function/class). Look for:
For section mode (file:line): read 30 lines of context around the target line.
Produce a single Markdown response with these sections (omit any that have no data):
## What it is
One sentence describing the symbol/file purpose.
## Why it exists (history)
- Created **YYYY-MM-DD** by **<author>** in commit `abc1234` ("commit message")
- Most recent substantive change: **YYYY-MM-DD** by **<author>** ("commit message")
- Originating PR: #N "<title>" (if known)
- Co-evolved with: <files frequently changed together>
## Why this shape (architectural context)
- Plan: `docs/plans/<plan-file>.md` motivated this design (cite the relevant section)
- Principle citations from AGENTS.md / CLAUDE.md: <list>
- Architectural-memory ranking: this is the **canonical** version of <pattern> / OR a **sibling** to <other symbols>
- Accepted technical debt: <relevant entries from AGENTS.md "Accepted Technical Debt">
## Near-duplicates / related code
If architectural-memory found similar symbols, list them with similarity scores:
| Sim | Symbol | Path | Purpose |
|---|---|---|---|
| 0.85 | `<other>` | `path:line` | <purpose> |
Note explicitly whether this is the canonical version or an alternate.
## Safe-change advice
Based on coupling + plan + principles:
- **Safe to change** (low coupling, no plan citations) — list any tests that will catch regressions
- **Change with care** (cited in plan, has near-duplicates) — list the plan section to update + sibling symbols to reconcile
- **Do not change without re-planning** (load-bearing per plan, frequently co-changed with multiple files) — recommend running `/plan` for the proposed change first
## Sources used
- arch-memory: <yes/no>
- git blame: <N lines>
- git log: <N commits>
- AGENTS.md/CLAUDE.md: <N matches>
- docs/plans/*.md: <N matches>
- file read: <bytes>
Keep the response under ~600 words. If a section is empty (e.g., no plan mentions), omit it rather than padding.
Every file:line this skill emits is a claim about a moment in history, so
pin it to the commit you read it at — scripts/explain-history.mjs:120 (a4ec98da). A
path alone is durable; a path plus a line is a snapshot that decays silently
into a wrong-but-resolving reference. Measured: of nine bad claims in one
verified document, five were correct when written and rotted afterwards.
Cite append-newest-first files (status.md, changelogs, session logs) by
section header, never by line — every new entry shifts every earlier line, so
those citations begin decaying immediately. Cite an untracked or off-disk path
as git show <sha>:<path>; it resolves to nothing for any other reader.
→ references/verification-discipline.md §1.
This skill is a multi-source synthesiser: its evidence comes from the repo + architectural-memory + git, gathered fresh each invocation. The files below cover specialised situations — read them when the trigger applies.
| File | Summary | Read when |
|---|---|---|
references/history-mode.md | History mode in full — the four sources searched, the Markdown digest template, and how to read the result. | The input is --history "<topic>" — before rendering the aggregator's JSON. |
references/verification-discipline.md | Verification discipline — pinned citations, figure provenance, two-direction proof, attribution, consumer-side checks. | Writing any file:line citation into the explanation — every one needs the commit it was read at (§1). |
references/worktree-preflight.md | Worktree preflight remedy — the skills:hydrate npm script to add when a linked worktree lacks the tooling tree. | A command dies with MODULE_NOT_FOUND in a linked worktree AND this repo has no skills:hydrate script. |
— end of /explain —
What SKILL.md sets; muted values are Claude Code's defaults
Generated from the plugin's indexed repository (lbstrydom/claude-engineering-skills) — no native marketplace selected
npx claudepluginhub p/lbstrydom-claude-engineering-skills18 skills in this plugin
/ai-context-managementManage AGENTS.md and CLAUDE.md alignment across a repo so Claude, Copilot,
Cursor, Windsurf, and other AI agents share the same project context.
Detects drift, reconciles manually-introduced divergence, and migrates legacy
CLAUDE.md-canonical repos to AGENTS.md-canonical.
Triggers on: "audit AGENTS.md", "check context drift", "AGENTS.md vs CLAUDE.md",
"fix context drift", "migrate to AGENTS.md",
"context sync", "what tools read which file", "ai-context-management".
Usage: /ai-context-management audit — Score drift + report findings
Usage: /ai-context-management reconcile — Apply patches to fix drift
Usage: /ai-context-management migrate — Flip legacy repo to AGENTS.md canonical
/audit-codeIteratively audit code against a plan with GPT + an independent final gate (Gemini, else Claude).
5-pass parallel static analysis (structure, wiring, backend, frontend,
sustainability), R2+ ledger-driven suppression, debt capture for
out-of-scope findings, max 6 rounds with 2-stable-rounds convergence.
Invoke this for ANY code-correctness review, even a small pasted snippet
or diff — don't just review it yourself directly; a single read-through
is not a substitute for the multi-pass GPT + final-gate adjudication this skill
performs, and skipping it means the review didn't actually happen.
Triggers on: "audit my code", "audit my changes", "audit my PR",
"check the implementation", "review my code", "audit code", "/audit-code",
"audit this", "verify the implementation".
Usage: /audit-code <plan-file> — Audit code against plan (--scope diff default)
Usage: /audit-code <plan-file> --scope plan — Audit only files mentioned in the plan
Usage: /audit-code <plan-file> --scope full — Full repo audit
/audit-planIteratively audit a plan file (docs/plans/*.md) with GPT + final gate (Gemini/Claude).
Multi-round refinement with an acceptance-rate early-stop (3 rounds default).
Ledger-driven suppression on R2+ rounds prevents finding churn.
Judges the plan DOCUMENT before anyone builds it. "Was the plan actually
built?" is /ux-lock verify — that reads a live app, this reads only the file.
Triggers on: "audit the plan", "iterate on the plan", "plan-audit",
"audit docs/plans/", "review the plan", "is this plan good",
"check the plan", "/audit-plan".
Usage: /audit-plan <plan-file> — Audit existing plan iteratively
Usage: /audit-plan <task-description> — Generate plan with /plan, then audit
/brainstormMulti-LLM concept-level brainstorming. Sends the user's topic to OpenAI
(and optionally Gemini) so the user can compare independent perspectives
alongside Claude's. Convergence is manual — Claude waits for the user
to ask for synthesis instead of auto-merging the views. Supports model
selection, repo-architecture context attachment (auto on arch topics),
a debate second round, depth budgets, session resume, extra context and
artifact attachment, and saving keeper insights from prior rounds.
Triggers on: "brainstorm", "let's think about", "get other LLMs on this",
"what would Gemini/GPT say", "/brainstorm".
Full command syntax: see the Usage section in this skill.
/click-testStructural DOM audit of a live app — walk every interactive element and
assert semantic-HTML contracts (duplicate IDs, orphan labels, inputs without
names, ARIA misuse, heading hierarchy, missing alt text, undersized touch
targets). Complements /persona-test: persona-test catches narrative UX issues
a real user would hit; click-test catches structural issues that hide in
JS-rendered surfaces and silently break assistive tech, form submissions, or
React reconciliation. Drives a browser via the shared driver contract; optional
--with-modals opens each modal/dropdown and rescans; device presets and
matrix mode cover responsive breakpoints.
Triggers on: "click test", "click-test", "structural audit", "DOM audit",
"accessibility audit", "duplicate ID check", "walk every element",
"audit the DOM", "structural QA", "/click-test".
Full command syntax: see the Usage section in this skill.
/cycleEnd-to-end feature cycle orchestrator. Runs the full skill chain in
sequence: /plan → /audit-plan → (wait for human implementation) →
/audit-code → /persona-test (if frontend/full-stack) → /ux-lock (if
fixes shipped) → /ship-checked. Use when starting a new feature or non-trivial
fix and you want the whole workflow on autopilot. Supports resuming from
an existing plan or straight to code-audit, per-step skips, max-round
pass-through, an opt-in autonomous mode that implements + audits each
plan cluster (the default still pauses for the human), and a remediate
mode that fixes triaged persona-test/audit findings against an accepted
plan with a focused audit and a rerun of only the affected journeys.
Triggers on: "run the full cycle", "do the whole flow", "plan + audit
+ ship", "feature cycle", "remediate the persona findings", "/cycle".
Full command syntax: see the Usage section in this skill.
Other plugins' skills for the same job