Documentation & Modernization
Two complementary workflows for a repository the user already has checked out
locally, bundled as one skill:
- Documentation mode — produce one definitive, cited architecture document
from the code on disk. Ideal for onboarding, system-design maps, or as the
evidence base for a modernization effort.
- Modernization mode — turn that architecture into a phased, safety-laddered
plan to upgrade, migrate, or rewrite a legacy system.
When to invoke
- "Document this codebase architecture."
- "Map this repository for onboarding."
- "Modernize or migrate this legacy system."
- "Create a phased upgrade plan from the current code."
Mode selection
- If the user wants to understand, document, map, research, or onboard onto a
codebase, run Documentation mode.
- If the user wants to modernize, migrate, upgrade, or rewrite a system, run
Modernization mode. Modernization mode is self-sufficient: if no
architecture document exists yet, it runs the Documentation mode workflow
first (in the same pass), then continues straight through to the plan.
When in doubt, produce the architecture document first — it is the audited
evidence base both modes rely on.
Documentation mode
Generate one definitive, cited architecture document for a repository the user
already has checked out locally. The goal is a writeup someone could hand to a
new engineer as their onboarding reference — broad enough to cover the whole
system, deep enough on the hard parts to be useful, and trustworthy because
every claim traces back to a file on disk.
Why local-first
Reading from the local checkout (not the GitHub API or the web) is the deliberate
default. It is faster, free, avoids rate limits, and — most importantly — it
describes the exact code in front of you rather than whatever main happens
to look like remotely. The one tradeoff is that remote-only facts (star counts,
full CI run history, sibling repos) aren't visible. That's fine: state those as
out-of-scope or mark them [UNVERIFIED] rather than guessing.
Local-first is not local-never-remote: a web/API lookup is a deliberate
last-resort fallback, reserved for a fact that genuinely cannot be determined
from disk and that materially matters to the document. When you do reach for it,
flag the result clearly (e.g. [UNVERIFIED] / sourced-remotely) so the reader
knows it didn't come from the checkout, and never let it become the easy path
that displaces reading the code on disk.
Procedure
- Establish identity first. Run
git remote -v, git branch --show-current,
and git log -1 so the document is anchored to a specific remote, branch, and
commit. A reader must be able to tell which snapshot this describes. Remote
URLs can contain embedded credentials (e.g. https://<token>@github.com/...)
— redact any credentials/tokens from the URL before recording it in the
document.
- Detect, don't assume. Read the real manifests (
go.mod, package.json,
Cargo.toml, pyproject.toml, pom.xml, etc.), the Makefile/task runner,
CI config, and any repo-specific agent or contributor docs (AGENTS.md,
CONTRIBUTING, README, docs/). These are the source of truth for the tech
stack and commands — prefer them over your prior knowledge of the framework.
- Map breadth, then drill into depth. First build the whole-repo map (the
three lenses below), then pick the 2-3 hardest subsystems and go deep on them.
- Verify as you go. Open the files you cite. If you reference a line number,
you should have actually read that line. Unsupported claims are worse than
omissions here — the whole value of this document is that it can be trusted.
Output structure
Produce a single Markdown file with the sections below, in this order. Adapt
the headings to the actual project (a CLI tool has no "frontend" lens — fold that
slot into whatever matters for that repo), but keep the three-lens shape and the
verification discipline.
Part 1 — Whole-repo technical deep-dive
- What the repository is (one paragraph, cited to README).
- Tech-stack detection table: layer | technology | evidence (file+line).
- Entry points (backend, frontend, CLI — whatever applies).
- Commands & Verification Inventory — a table of the canonical project
commands (
command | purpose | evidence), verified against the task runner /
manifests / CI config, not guessed. Cover build, run/serve, test (and how to
run a single test), lint, format, and — where they exist — typecheck,
end-to-end/smoke, contract, and any other gate commands, plus the CI
workflow(s) that run them and on what trigger. Also record whether CI is
enforced — i.e. whether any workflow is a required status check /
branch-protection rule that actually blocks merges, versus one that merely
runs — since that distinction is a manual, human-configured setting that
Modernization mode must surface, not assume. Enforcement usually cannot be
determined from the local checkout alone: ask the user, or mark it
[UNVERIFIED] unless confirmed from an authoritative source (any remote
lookup is a flagged last resort, per the local-first rule above). This
inventory is the source of
truth that downstream planning (Modernization mode) cites so its exit
criteria are runnable, not aspirational. Detect these per-ecosystem (npm/yarn/
pnpm, make, just, cargo, go, poetry/tox/nox, gradle/maven,
etc.) — do not assume a stack. Mark any command you could not verify
[UNVERIFIED].
- Directory layout for each major area, with a one-line purpose per directory.
- Deployment & Runtime Surface — a table of every place the language/runtime
and backing-service versions are pinned for running the system (not just
building it): container base images (
Dockerfile/Containerfile,
docker-compose* build contexts), CI runner images / setup-* versions,
engines/.nvmrc/.tool-versions/runtime.txt, serverless/lambda runtimes,
and stateful data-store image tags (DB/cache/broker/search). Cite each with
file+line. This surface is what a later platform/runtime bump must move in
lockstep — flag any drift between build-runtime and run-runtime here so it's
visible before a modernization plan is written.
- EOL / dead-dependency scan — call out frameworks, runtimes, base images,
and libraries that are end-of-life, unmaintained, or removed in a likely target
major (e.g. a framework whose next major renames namespaces or drops a
component family). Mark each
[INFERRED]/[UNVERIFIED] as appropriate. This is
the raw material Modernization mode's feasibility spike and hazard red-team
build on.
- Data/storage layers, APIs, plugins/extensions, background jobs, CI/CD, testing.
Part 2 — Context & ecosystem
- Local checkout identity table (remote, branch, HEAD commit, version, license).
- Repo-specific agent/contributor docs present, and what rules they encode.
- Developer gotchas (test watch-mode defaults, slow builds, codegen-must-commit,
pre-commit hooks) — each cited.
- How this project relates to its broader ecosystem or sibling services, as
visible from disk (build tags, optional linked repos, separately-deployable
components). Don't import remote ecosystem trivia.
Part 3 — Architectural blueprint
- Tech-stack summary (can reference the Part 1 table).
- C4-style diagrams as Mermaid: Level 1 system context, Level 2 containers,
Level 3 a representative request/component lifecycle.
- Layering and dependency rules (what may depend on what, and what enforces it).
- Cross-cutting concerns table: auth, config, logging, metrics/tracing, secrets,
error handling, feature flags — each with its location and evidence.
- Inferred Architectural Decision Records (reconstructed from code + docs).
- Governance & enforcement mechanisms (CI gates, codegen verification,
CODEOWNERS, review gates, compatibility rules).
- "How to add a feature" guide plus common pitfalls.
Subsystem deep-dives
Identify the 2-3 most complex or architecturally significant subsystems — the
parts a new engineer would most struggle with, such as an evaluation/scheduling
engine, a plugin loader pipeline, a state machine, or a rendering/migration
framework. For each, add a dedicated subsection covering its internal structure,
lifecycle or state machine, key types, and data flow, with local file+line
citations and a small Mermaid diagram where it clarifies the flow. This is what
separates a useful onboarding doc from a directory listing — spend real effort
here.
Confidence assessment
A table of the major claim areas rated High / Inferred / Unverified, so a
reader knows exactly which parts to trust outright and which to double-check.
Footnotes — local file citations
A list of the key local files the document relies on, each with a one-line note
on what it establishes.
Conventions that make the document trustworthy
These are the habits that distinguish this skill's output from a generic
overview. They matter because the document's entire value is that a reader can
rely on it without re-deriving everything.
- Cite every non-obvious claim to a local path, with a line number where it
pins something specific (
pkg/server/server.go#L39-L41). Relative paths from
the repo root keep links clickable.
- Mark uncertainty honestly. Use
[INFERRED] for something you reasoned to
but didn't see stated, and [UNVERIFIED] for something you're repeating but
didn't confirm (e.g. a build-timing claim from a doc you didn't re-measure).
Honest gaps are more useful than false confidence.
- Resolve contradictions, don't restate them. If two sources disagree (say a
version literal in code vs. the manifest), go read the code, decide the real
answer, and label it
[Resolved contradiction] with the explanation. Leaving
a reader to puzzle over a conflict is a failure mode.
- Note compatibility and deploy-cadence rules the repo enforces — separate
FE/BE PRs, bidirectional storage compatibility, additive-only protobuf changes
— because these are the rules a newcomer most easily breaks.
- Prefer precise counts over vague ones. "73 service packages", "89 workflow
files" (from a directory listing) reads as verified; "many services" reads as a
guess.
Scope control
Keep the document grounded in the checkout. It's easy to drift outward into the
project's wider ecosystem (related products, README marketing, satellite repos)
— resist that unless it's visible on disk, and clearly label anything that comes
from outside the local tree. The reader asked for this codebase, documented
faithfully.
Extended reference
Additional detailed guidance was moved to references/extended-guide.md to keep this skill within the progressive-disclosure budget.
Progressive disclosure and bundled resources
At discovery time, only name and description are loaded. Read or execute bundled resources only when the current task needs them.
references/extended-guide.md: expanded documentation and modernization guidance.
references/migration-hazards.md: runtime, framework, data, and compatibility hazards.
references/copilot-instructions.template.md: optional instructions template when requested.
Output template
## Documentation and modernization result
**Status:** documented | modernization plan created | blocked
**Mode:** <Documentation | Modernization>
**Snapshot:** `<remote redacted>`, `<branch>`, `<HEAD commit>`
### Deliverables
- Architecture document: `<path or inline>`
- Modernization plan: `<path, inline, or n/a>`
### Key evidence
| Claim area | Confidence | Evidence |
| --- | --- | --- |
| Tech stack | High | `<file#line>` |
Quality gate
1---2name: doc-and-modernize3description: Two related workflows for a locally-cloned codebase, in one skill. Use this skill when enforced*** — i.e. whether any workflow is a **required status check /; branch-protection rule** that actually blocks merges, versus one that merely; runs — since that distinction is a manual, human-configured setting that.4---56<!-- Generated from harness/github-copilot/skills/doc-and-modernize/SKILL.md by harness/claude-code/scripts/convert_from_copilot.py. Edit the source, not this file. -->78# Documentation & Modernization910Two complementary workflows for a repository the user already has checked out11locally, bundled as one skill:1213- **Documentation mode** — produce one definitive, cited architecture document14 from the code on disk. Ideal for onboarding, system-design maps, or as the15 evidence base for a modernization effort.16- **Modernization mode** — turn that architecture into a phased, safety-laddered17 plan to upgrade, migrate, or rewrite a legacy system.1819## When to invoke2021- "Document this codebase architecture."22- "Map this repository for onboarding."23- "Modernize or migrate this legacy system."24- "Create a phased upgrade plan from the current code."2526## Mode selection2728- If the user wants to **understand, document, map, research, or onboard onto** a29 codebase, run **Documentation mode**.30- If the user wants to **modernize, migrate, upgrade, or rewrite** a system, run31 **Modernization mode**. Modernization mode is self-sufficient: if no32 architecture document exists yet, it runs the **Documentation mode** workflow33 first (in the same pass), then continues straight through to the plan.3435When in doubt, produce the architecture document first — it is the audited36evidence base both modes rely on.3738## Documentation mode3940Generate one definitive, cited architecture document for a repository the user41already has checked out locally. The goal is a writeup someone could hand to a42new engineer as their onboarding reference — broad enough to cover the whole43system, deep enough on the hard parts to be useful, and trustworthy because44every claim traces back to a file on disk.4546### Why local-first4748Reading from the local checkout (not the GitHub API or the web) is the deliberate49**default**. It is faster, free, avoids rate limits, and — most importantly — it50describes *the exact code in front of you* rather than whatever `main` happens51to look like remotely. The one tradeoff is that remote-only facts (star counts,52full CI run history, sibling repos) aren't visible. That's fine: state those as53out-of-scope or mark them `[UNVERIFIED]` rather than guessing.5455Local-first is not local-*never*-remote: a web/API lookup is a deliberate56**last-resort fallback**, reserved for a fact that genuinely cannot be determined57from disk and that materially matters to the document. When you do reach for it,58flag the result clearly (e.g. `[UNVERIFIED]` / sourced-remotely) so the reader59knows it didn't come from the checkout, and never let it become the easy path60that displaces reading the code on disk.6162### Procedure63641. **Establish identity first.** Run `git remote -v`, `git branch --show-current`,65 and `git log -1` so the document is anchored to a specific remote, branch, and66 commit. A reader must be able to tell which snapshot this describes. Remote67 URLs can contain embedded credentials (e.g. `https://<token>@github.com/...`)68 — **redact any credentials/tokens** from the URL before recording it in the69 document.702. **Detect, don't assume.** Read the real manifests (`go.mod`, `package.json`,71 `Cargo.toml`, `pyproject.toml`, `pom.xml`, etc.), the `Makefile`/task runner,72 CI config, and any repo-specific agent or contributor docs (`AGENTS.md`,73 `CONTRIBUTING`, `README`, `docs/`). These are the source of truth for the tech74 stack and commands — prefer them over your prior knowledge of the framework.753. **Map breadth, then drill into depth.** First build the whole-repo map (the76 three lenses below), then pick the 2-3 hardest subsystems and go deep on them.774. **Verify as you go.** Open the files you cite. If you reference a line number,78 you should have actually read that line. Unsupported claims are worse than79 omissions here — the whole value of this document is that it can be trusted.8081### Output structure8283Produce a **single Markdown file** with the sections below, in this order. Adapt84the headings to the actual project (a CLI tool has no "frontend" lens — fold that85slot into whatever matters for that repo), but keep the three-lens shape and the86verification discipline.8788#### Part 1 — Whole-repo technical deep-dive89- What the repository is (one paragraph, cited to README).90- Tech-stack detection table: layer | technology | evidence (file+line).91- Entry points (backend, frontend, CLI — whatever applies).92- **Commands & Verification Inventory** — a table of the canonical project93 commands (`command | purpose | evidence`), verified against the task runner /94 manifests / CI config, not guessed. Cover build, run/serve, test (and how to95 run a single test), lint, format, and — where they exist — typecheck,96 end-to-end/smoke, contract, and any other gate commands, plus the CI97 workflow(s) that run them and on what trigger. **Also record whether CI is98 *enforced*** — i.e. whether any workflow is a **required status check /99 branch-protection rule** that actually blocks merges, versus one that merely100 runs — since that distinction is a manual, human-configured setting that101 Modernization mode must surface, not assume. Enforcement usually cannot be102 determined from the local checkout alone: ask the user, or mark it103 `[UNVERIFIED]` unless confirmed from an authoritative source (any remote104 lookup is a flagged last resort, per the local-first rule above). This105 inventory is the source of106 truth that downstream planning (Modernization mode) cites so its exit107 criteria are runnable, not aspirational. Detect these per-ecosystem (npm/yarn/108 pnpm, `make`, `just`, `cargo`, `go`, `poetry`/`tox`/`nox`, `gradle`/`maven`,109 etc.) — do not assume a stack. Mark any command you could not verify110 `[UNVERIFIED]`.111- Directory layout for each major area, with a one-line purpose per directory.112- **Deployment & Runtime Surface** — a table of every place the language/runtime113 and backing-service versions are pinned *for running* the system (not just114 building it): container base images (`Dockerfile`/`Containerfile`,115 `docker-compose*` build contexts), CI runner images / `setup-*` versions,116 `engines`/`.nvmrc`/`.tool-versions`/`runtime.txt`, serverless/lambda runtimes,117 and stateful data-store image tags (DB/cache/broker/search). Cite each with118 file+line. This surface is what a later platform/runtime bump must move in119 lockstep — flag any drift between build-runtime and run-runtime here so it's120 visible before a modernization plan is written.121- **EOL / dead-dependency scan** — call out frameworks, runtimes, base images,122 and libraries that are end-of-life, unmaintained, or removed in a likely target123 major (e.g. a framework whose next major renames namespaces or drops a124 component family). Mark each `[INFERRED]`/`[UNVERIFIED]` as appropriate. This is125 the raw material Modernization mode's feasibility spike and hazard red-team126 build on.127- Data/storage layers, APIs, plugins/extensions, background jobs, CI/CD, testing.128129#### Part 2 — Context & ecosystem130- Local checkout identity table (remote, branch, HEAD commit, version, license).131- Repo-specific agent/contributor docs present, and what rules they encode.132- Developer gotchas (test watch-mode defaults, slow builds, codegen-must-commit,133 pre-commit hooks) — each cited.134- How this project relates to its broader ecosystem or sibling services, *as135 visible from disk* (build tags, optional linked repos, separately-deployable136 components). Don't import remote ecosystem trivia.137138#### Part 3 — Architectural blueprint139- Tech-stack summary (can reference the Part 1 table).140- C4-style diagrams as Mermaid: Level 1 system context, Level 2 containers,141 Level 3 a representative request/component lifecycle.142- Layering and dependency rules (what may depend on what, and what enforces it).143- Cross-cutting concerns table: auth, config, logging, metrics/tracing, secrets,144 error handling, feature flags — each with its location and evidence.145- Inferred Architectural Decision Records (reconstructed from code + docs).146- Governance & enforcement mechanisms (CI gates, codegen verification,147 CODEOWNERS, review gates, compatibility rules).148- "How to add a feature" guide plus common pitfalls.149150#### Subsystem deep-dives151Identify the 2-3 most complex or architecturally significant subsystems — the152parts a new engineer would most struggle with, such as an evaluation/scheduling153engine, a plugin loader pipeline, a state machine, or a rendering/migration154framework. For each, add a dedicated subsection covering its internal structure,155lifecycle or state machine, key types, and data flow, with local file+line156citations and a small Mermaid diagram where it clarifies the flow. This is what157separates a useful onboarding doc from a directory listing — spend real effort158here.159160#### Confidence assessment161A table of the major claim areas rated **High / Inferred / Unverified**, so a162reader knows exactly which parts to trust outright and which to double-check.163164#### Footnotes — local file citations165A list of the key local files the document relies on, each with a one-line note166on what it establishes.167168### Conventions that make the document trustworthy169170These are the habits that distinguish this skill's output from a generic171overview. They matter because the document's entire value is that a reader can172rely on it without re-deriving everything.173174- **Cite every non-obvious claim** to a local path, with a line number where it175 pins something specific (`pkg/server/server.go#L39-L41`). Relative paths from176 the repo root keep links clickable.177- **Mark uncertainty honestly.** Use `[INFERRED]` for something you reasoned to178 but didn't see stated, and `[UNVERIFIED]` for something you're repeating but179 didn't confirm (e.g. a build-timing claim from a doc you didn't re-measure).180 Honest gaps are more useful than false confidence.181- **Resolve contradictions, don't restate them.** If two sources disagree (say a182 version literal in code vs. the manifest), go read the code, decide the real183 answer, and label it `[Resolved contradiction]` with the explanation. Leaving184 a reader to puzzle over a conflict is a failure mode.185- **Note compatibility and deploy-cadence rules** the repo enforces — separate186 FE/BE PRs, bidirectional storage compatibility, additive-only protobuf changes187 — because these are the rules a newcomer most easily breaks.188- **Prefer precise counts over vague ones.** "73 service packages", "89 workflow189 files" (from a directory listing) reads as verified; "many services" reads as a190 guess.191192### Scope control193194Keep the document grounded in the checkout. It's easy to drift outward into the195project's wider ecosystem (related products, README marketing, satellite repos)196— resist that unless it's visible on disk, and clearly label anything that comes197from outside the local tree. The reader asked for *this codebase*, documented198faithfully.199## Extended reference200201Additional detailed guidance was moved to [references/extended-guide.md](references/extended-guide.md) to keep this skill within the progressive-disclosure budget.202203204## Progressive disclosure and bundled resources205206At discovery time, only `name` and `description` are loaded. Read or execute bundled resources only when the current task needs them.207208- `references/extended-guide.md`: expanded documentation and modernization guidance.209- `references/migration-hazards.md`: runtime, framework, data, and compatibility hazards.210- `references/copilot-instructions.template.md`: optional instructions template when requested.211212## Output template213214```markdown215## Documentation and modernization result216217**Status:** documented | modernization plan created | blocked218**Mode:** <Documentation | Modernization>219**Snapshot:** `<remote redacted>`, `<branch>`, `<HEAD commit>`220221### Deliverables222- Architecture document: `<path or inline>`223- Modernization plan: `<path, inline, or n/a>`224225### Key evidence226| Claim area | Confidence | Evidence |227| --- | --- | --- |228| Tech stack | High | `<file#line>` |229```230231## Quality gate232233- [ ] The document is grounded in the local checkout, not remote assumptions.234- [ ] Repository identity includes redacted remote, branch, and HEAD commit.235- [ ] Stack, commands, CI triggers, runtime pins, and deployment surface are cited to files.236- [ ] CI enforcement is confirmed by an authoritative source or marked `[UNVERIFIED]`.