agentleFS
ForeverScForeverSc/ai-handrail/skills/legacy-discovery/SKILL.md

legacy-discovery

Skill1 starsChanged 9 months agoMITView on GitHub

Use when starting work on an unfamiliar legacy project, inherited codebase, or large old system. Triggers when user says "understand this project", "what does this codebase do", "analyze this legacy system", "map this project", or wants to explore an existing codebase before making changes.

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. sarveshtalele/mcp-skills-registry★ 2same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository5 other files it gives its agents.

The file

Show its rules and text

We split this skill into the rules it gives an agent

27 rules. About 0 are common, 21 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈21

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before planning any modernization work

    line 18
  2. Distinctive:

    When the user says "help me understand this project"

    line 19
  3. Distinctive:

    Before reading any code, determine scope with the user:

    line 25
  4. Distinctive:

    Ask: which domain / feature / subsystem should we focus on?

    line 27
  5. Distinctive:

    If user says "the whole thing" — push back.

    line 28
  6. Distinctive:

    Before deep reconnaissance, determine the project's technical profile:

    line 33
  7. Distinctive:

    If no profile matches (CLI tool, data pipeline, library, etc.), proceed with base workflow only.

    line 48
  8. Distinctive:

    Dependency snapshot: Read lockfile. Record actual versions of key dependencies (framework, router, state management, test runner, bundler).

    line 58
  9. Distinctive:

    Profile-specific reconnaissance: If a profile was loaded in Step 2, also complete the profile's reconnaissance checklist.

    line 63
  10. Distinctive:

    If a profile is loaded, consult its Critical Path Patterns section for stack-specific guidance on where P0 flows typically live.

    line 74
  11. Distinctive:

    If a profile is loaded, also evaluate the profile's Risk Assessment Focus table and assign any profile-specific risk labels where …

    line 89
  12. Very specific:

    Run targeted analyses to reveal hidden risks.

    line 93
  13. Distinctive:

    Use project-appropriate tools (madge, dependency-cruiser, etc.) to generate import graphs

    line 96
  14. Distinctive:

    Use static analysis tools appropriate to the stack (ts-prune, knip, vulture, deadcode, etc.)

    line 108
  15. Distinctive:

    Do NOT delete — only mark.

    line 110
  16. Very specific:

    Prefer mermaid when the target docs can render it

    line 120
  17. Distinctive:

    Use the flowchart to show surprising branches, retries, fallbacks, and side effects

    line 121
  18. Very specific:

    If the API cannot be confirmed from code or matching-version docs, mark it UNVERIFIED

    line 125
  19. Very specific:

    Use templates from templates/project-overview.md and templates/domain-overview.md.

    line 158
  20. Distinctive:

    Read-only: Do not create, modify, or delete any project files.

    line 162
  21. Distinctive:

    One area per round: Never attempt to understand the entire project at once.

    line 163
  22. Very specific:

    No assumptions: If you can't verify something from code, mark it UNKNOWN.

    line 164
  23. Distinctive:

    Existing code over examples: When understanding how a library is used, look at the project's own usage first.

    line 166
  24. Distinctive:

    Complex logic needs a flowchart: If prose alone would hide branching or state, add a flowchart.

    line 167
  25. Distinctive:

    High-impact old dependencies require source inspection: Do not rely on generic memory when the pinned API may differ.

    line 169
  26. Very specific:

    Ask before assuming business intent: When code logic implies a business rule, flag it as HUMAN-REVIEW rather than interpreting it.

    line 171
  27. Distinctive:

    Before ending a round, answer:

    line 186

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Legacy Discovery

Understand a legacy project without touching any code. Produce a structured analysis that subsequent skills can consume.

Goal

Build a mental model of the project: what it does, how it's structured, what's critical, what's risky, and what's unknown — all without modifying a single file.

When to Use

  • First contact with a legacy codebase
  • Onboarding to an inherited project
  • Before planning any modernization work
  • When the user says "help me understand this project"

Mandatory Workflow

Step 1: Establish Boundaries

Before reading any code, determine scope with the user:

  1. Ask: which domain / feature / subsystem should we focus on?
  2. If user says "the whole thing" — push back. Negotiate one starting area.
  3. Confirm: we will analyze [specific area] this round. Everything else is out of scope.

Step 2: Identify Project Type

Before deep reconnaissance, determine the project's technical profile:

  1. Scan project metadata files (package.json, go.mod, pom.xml, pyproject.toml, etc.)
  2. Match against detection signals defined in profiles/:
SignalProfile
package.json with react/vue/angular/svelteprofiles/frontend.md
package.json with express/koa/fastify/nestjsprofiles/backend-node.md
pom.xml or build.gradle with Spring/Quarkus/Micronautprofiles/backend-java.md
requirements.txt/pyproject.toml with django/flask/fastapiprofiles/backend-python.md
go.mod with web framework or net/http usageprofiles/backend-go.md
Both frontend AND backend signals presentprofiles/fullstack.md
  1. Load the matched profile. The profile provides additional reconnaissance items, critical path patterns, risk factors, structural analysis tools, and stack-specific risk labels.
  2. If no profile matches (CLI tool, data pipeline, library, etc.), proceed with base workflow only.
  3. Record the detected project type in outputs: Project Type: [frontend | backend-node | backend-java | backend-python | backend-go | fullstack | unclassified]

Step 3: Reconnaissance (read-only)

Gather facts. Do NOT interpret yet.

Base reconnaissance (all project types):

  1. Project metadata: package.json, Makefile, Dockerfile, CI configs, build scripts
  2. Dependency snapshot: Read lockfile. Record actual versions of key dependencies (framework, router, state management, test runner, bundler).
  3. Entry points: main, index, app, route definitions, CLI entry
  4. Directory structure: Top-level layout, naming conventions, module organization
  5. Configuration: Environment files, feature flags, config objects

Profile-specific reconnaissance: If a profile was loaded in Step 2, also complete the profile's reconnaissance checklist. The profile checklist extends (not replaces) the base items above.

Step 4: Identify Critical Paths (80/20)

Find the P0 flows — the paths that, if broken, cause revenue loss or user-facing failures:

  1. Trace 1-3 core user journeys through the code
  2. Mark every file/module touched by these journeys
  3. Identify shared utilities and data stores these paths depend on
  4. Note external integrations (APIs, databases, message queues)

If a profile is loaded, consult its Critical Path Patterns section for stack-specific guidance on where P0 flows typically live.

Step 5: Risk Assessment

For each area in scope, evaluate:

  • Complexity: cyclomatic complexity, deep nesting, god files/classes
  • Test coverage: existing tests? what kind? what's missing?
  • Documentation: inline comments, READMEs, ADRs, wiki links
  • Coupling: how tangled is this with other modules?
  • Staleness: dead code, deprecated APIs, TODO/FIXME/HACK comments
  • Non-standard behavior: direct state mutation, hidden global writes, order-dependent behavior, or legacy side effects that defeat normal intuition

Assign risk labels: P0-CRITICAL, HIGH-RISK, LEGACY-SEALED, SAFE-TO-EXTRACT, DOC-MISSING, TEST-MISSING, HUMAN-REVIEW, DEAD-CODE, CIRCULAR-DEP, HOTSPOT.

If a profile is loaded, also evaluate the profile's Risk Assessment Focus table and assign any profile-specific risk labels where applicable.

Step 6: Structural Analysis

Run targeted analyses to reveal hidden risks. See docs/methodology.md → Advanced Techniques for full details. If a profile is loaded, prefer the tools listed in its Structural Analysis Tools table.

Dependency graph analysis:

  • Use project-appropriate tools (madge, dependency-cruiser, etc.) to generate import graphs
  • Identify circular dependencies → tag CIRCULAR-DEP
  • Identify god modules (high fan-in) — dangerous to change, many callers affected
  • Identify orphan modules (zero imports) — potential dead code

Hotspot analysis (knowledge archaeology):

  • git log --format=format: --name-only | sort | uniq -c | sort -rn — find high-churn files
  • git log --follow on critical files to trace decision history
  • git blame on business-critical sections to find when/why rules were introduced
  • High churn + high complexity = HOTSPOT label

Dead code detection:

  • Use static analysis tools appropriate to the stack (ts-prune, knip, vulture, deadcode, etc.)
  • Mark unused exports, unreachable branches, never-called functions → DEAD-CODE
  • Do NOT delete — only mark. Dead code removal is a refactor task.

Seam identification:

  • Find points where behavior can be altered without editing surrounding code
  • Examples: function boundaries, DI injection points, interface implementations, middleware hooks, config switches
  • Mark seams in module map: SEAM: [description]
  • These are where future adapters/wrappers will attach

Complex-logic capture:

  • For state-heavy, branch-heavy, or multi-module flows, produce a flowchart in addition to prose notes
  • Prefer mermaid when the target docs can render it
  • Use the flowchart to show surprising branches, retries, fallbacks, and side effects

Dependency verification:

  • For high-impact outdated packages, you must record the pinned version, project-local usages, and package source inspection
  • If the API cannot be confirmed from code or matching-version docs, mark it UNVERIFIED

Step 7: Map Unknowns

Explicitly list:

  • Business rules that are unclear from code alone
  • Implicit behaviors that might be relied upon downstream
  • Magic numbers, unexplained conditions, commented-out code blocks
  • Areas where you'd need human confirmation before proceeding

Step 8: Produce Outputs

Generate the required outputs (see below). Write to docs/legacy-modernization/. Discovery produces analysis documents only — it does NOT modify project source code.

Required Outputs

Each discovery round MUST produce:

OutputDescription
Project typeDetected profile (frontend, backend-node, backend-java, backend-python, backend-go, fullstack, or unclassified)
Scope statementWhat was analyzed, what was excluded
Project objectiveWhat this project/domain does (in business terms)
Critical path mapP0 user journeys with file/module trace
Dependency snapshotKey deps with actual versions from lockfile
Complex flowchart setFlowchart output for complex logic in scope
Risk inventoryPer-module risk labels with justification
Structural analysisDependency graph, circular deps, hotspots, dead code, seams
Unknown registryExplicit list of things not yet understood
Human decision pointsQuestions that require human answers
Next-round recommendationWhat to analyze next and why

Use templates from templates/project-overview.md and templates/domain-overview.md.

Hard Rules

  1. Read-only. Do not create, modify, or delete any project files. Only create documentation files.
  2. One area per round. Never attempt to understand the entire project at once.
  3. No assumptions. If you can't verify something from code, mark it UNKNOWN.
  4. Lockfile over docs. Real dependency versions come from lockfiles, not READMEs or external sites.
  5. Existing code over examples. When understanding how a library is used, look at the project's own usage first.
  6. Complex logic needs a flowchart. If prose alone would hide branching or state, add a flowchart.
  7. Hidden traps must be surfaced. Non-standard legacy behavior should be documented as an explicit risk, not buried in narrative text.
  8. High-impact old dependencies require source inspection. Do not rely on generic memory when the pinned API may differ.
  9. Surface unknowns. It's acceptable to not know something. It's unacceptable to hide that you don't know.
  10. Ask before assuming business intent. When code logic implies a business rule, flag it as HUMAN-REVIEW rather than interpreting it.

Anti-Patterns

Don'tDo instead
Scan every file in a large projectPick one domain, trace one critical path
Assume latest API docs applyRead the lockfile, check project's actual usage
Skip dependency version identificationAlways record framework/library versions from lockfile
Guess at business rulesMark them UNKNOWN + HUMAN-REVIEW
Produce a single massive analysis docProduce focused outputs per the template structure
Claim "analysis complete" after one roundState what was covered AND what wasn't

Round Completion

Before ending a round, answer:

  1. Analyzed: [specific area/path]
  2. Confirmed: [list of confirmed facts]
  3. Unknown: [list of unresolved items]
  4. Next: [recommended next area + rationale]

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.