agentleFS
tuana-vntuana-vn/system-reverse-engineer/.github/skills/architecture-reconstruction-and-diagrams/SKILL.md

architecture-reconstruction-and-diagrams

Skill0 starsChanged 2 months agoMITView on GitHub

Reconstruct a consumer-usable current-system architecture model from verified source evidence, emphasizing responsibilities, dependencies, runtime relationships, system boundaries, and evidence-linked Mermaid diagrams rather than file inventories.

The file

Show its rules and text

We split this skill into the rules it gives an agent

15 rules. About 0 are common, 10 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈10

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Do not produce a package-count diagram.

    line 78
  2. Very specific:

    Use a Mermaid sequenceDiagram when the behavior is sequential/collaborative.

    line 93
  3. Distinctive:

    Every material node and edge must be supportable from current source evidence.

    line 116
  4. Distinctive:

    Do not invent components merely to make a diagram visually complete.

    line 125
  5. Very specific:

    Use NOT_APPLICABLE with evidence where a model dimension truly does not apply.

    line 139
  6. Distinctive:

    Every generated Mermaid diagram MUST use syntax that belongs to exactly one Mermaid diagram type.

    line 159
  7. Distinctive:

    Do not use flowchart node declarations such as:

    line 211
  8. Distinctive:

    Before persisting any Mermaid block:

    line 222
  9. Distinctive:

    Check every connector/message against that diagram type.

    line 225
  10. Very specific:

    Ensure every message with : in a sequence diagram has non-empty text after the colon.

    line 228
  11. Very specific:

    Prefer quoted flowchart node labels when labels contain <br/>, punctuation, parentheses, brackets, or method names.

    line 229
  12. Distinctive:

    Keep diagram syntax minimal.

    line 230
  13. Distinctive:

    If uncertain whether a diagram will parse, simplify it rather than emitting speculative Mermaid syntax.

    line 231
  14. Very specific:

    If the requested artifact is Component Architecture, it MUST remain a component/dependency graph.

    line 284
  15. Distinctive:

    Before persisting a mandatory diagram, verify both:

    line 311

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

Architecture Reconstruction and Diagrams — 4.0

Mission

Turn verified repository evidence into an understandable model of the current system.

The goal is not to inventory files. The goal is to answer:

what owns each major responsibility?
what calls what?
what crosses a boundary?
where is state owned?
what selects runtime variants?
what happens on failure?

Relationship-First Rule

Prefer:

responsibility + relationship + behavior + evidence

over:

package name + file count + class list

File counts may appear as supporting topology context only. They are never sufficient architecture.

Major Subsystem Model

For every material subsystem, record all applicable fields:

SubsystemEntryResponsibilityInputsOutputsDependenciesState OwnershipFailure BehaviorRuntime/Config SelectionEvidence

A material subsystem is not considered MODELED while an applicable field is blank or asserted without evidence.

Mandatory Diagram Set for Full Baseline

A full repository baseline must create these Mermaid-backed artifacts under docs/reverse-engineering/diagrams/:

01_system_context.md
02_component_architecture.md
03_primary_runtime_sequence.md
04_integration_boundaries.md
05_state_persistence_lifecycle.md

Each file must contain at least one valid mermaid fenced block and an Evidence Anchors section.

01 — System Context

Show:

  • external actors/systems
  • application boundary
  • major inbound surfaces
  • major outbound dependencies

02 — Component Architecture

Show:

  • major runtime components/subsystems
  • dependency direction
  • ownership/responsibility boundaries
  • material runtime variant points

Do not produce a package-count diagram.

03 — Primary Runtime Sequence

Show at least one externally significant end-to-end runtime flow:

entry
→ validation/conversion
→ orchestration/domain
→ integration/persistence
→ result/error mapping
→ observable response/effect

Use a Mermaid sequenceDiagram when the behavior is sequential/collaborative.

04 — Integration Boundaries

Show:

  • abstractions/adapters
  • selectors/factories/bindings
  • concrete integrations
  • external systems/processes
  • fallback or alternate routes where material

05 — State / Persistence / Lifecycle

Show the most material state-bearing lifecycle. Prefer:

  • persistence ownership and read/write flow;
  • background-job lifecycle;
  • resource/session/thread lifecycle;
  • state transitions.

For systems without persistence, model another material state/lifecycle concern rather than omitting the diagram.

Diagram Evidence Rule

Every material node and edge must be supportable from current source evidence.

Each diagram artifact must include:

## Evidence Anchors
- <repo-relative path> — <symbol/method/class/config key> — <what it proves>

Do not invent components merely to make a diagram visually complete.

Output Model Artifacts

Create/update:

docs/reverse-engineering/models/component_catalog.md
docs/reverse-engineering/models/runtime_flow_catalog.md
docs/reverse-engineering/models/integration_catalog.md
docs/reverse-engineering/models/configuration_model.md
docs/reverse-engineering/models/persistence_state_model.md

Use NOT_APPLICABLE with evidence where a model dimension truly does not apply.

Completion Gate

Architecture synthesis is incomplete if any of the following is true:

[ ] fewer than 5 mandatory diagram artifacts exist
[ ] any mandatory diagram lacks Mermaid
[ ] any mandatory diagram lacks evidence anchors
[ ] a material subsystem lacks responsibility
[ ] a material subsystem lacks dependencies
[ ] a material subsystem lacks state/failure/selection classification where applicable
[ ] primary runtime behavior exists only as prose/class lists with no sequence model
[ ] integration boundaries exist but no boundary model exists

Mermaid Syntax Safety Contract

Every generated Mermaid diagram MUST use syntax that belongs to exactly one Mermaid diagram type.

Flowchart / graph rules

For diagrams beginning with:

graph TD
graph LR
flowchart TD
flowchart LR

use flowchart edges only.

Valid:

REST --> VALIDATOR
REST -->|validate()| VALIDATOR
PARSER -.-> LOGIC

Invalid in a flowchart:

REST->>VALIDATOR: validate()
REST-->>MODEL: result

->> and -->> are sequence-diagram message operators and MUST NOT appear in a graph/flowchart.

Sequence diagram rules

For diagrams beginning with:

sequenceDiagram

declare participants and use sequence-message syntax.

Valid:

participant REST as REST Handler
participant VALIDATOR as Validator

REST->>VALIDATOR: validate()
VALIDATOR-->>REST: valid

Do not use flowchart node declarations such as:

REST[REST Handler]
VALIDATOR["Validator"]

inside a sequence diagram.

Mandatory self-check before writing a Mermaid artifact

Before persisting any Mermaid block:

  1. Identify its declared diagram type from the first Mermaid statement.
  2. Check every connector/message against that diagram type.
  3. For graph/flowchart, reject any line containing ->> or -->>.
  4. For sequenceDiagram, reject flowchart-style node declarations (ID[...], ID(...), ID{...}).
  5. Ensure every message with : in a sequence diagram has non-empty text after the colon.
  6. Prefer quoted flowchart node labels when labels contain <br/>, punctuation, parentheses, brackets, or method names.
  7. Keep diagram syntax minimal; do not mix diagram grammars for visual convenience.
  8. If uncertain whether a diagram will parse, simplify it rather than emitting speculative Mermaid syntax.

A diagram that does not pass this self-check MUST NOT be counted toward mandatory diagram coverage.

Canonical examples

Component/architecture diagram:

graph TD
    REST["REST Handler<br/>SnapshotGroupHandler"]
    VALIDATOR["Validator<br/>SnapshotGroupValidator"]
    LOGIC["Logic<br/>GetSnapshotGroupLogic"]

    REST -->|validate()| VALIDATOR
    REST -->|getSnapshotGroups()| LOGIC

Runtime sequence:

sequenceDiagram
    participant REST as SnapshotGroupHandler
    participant VALIDATOR as SnapshotGroupValidator
    participant LOGIC as GetSnapshotGroupLogic

    REST->>VALIDATOR: validate()
    VALIDATOR-->>REST: valid
    REST->>LOGIC: getSnapshotGroups()
    LOGIC-->>REST: result

Semantic Diagram Type Contract

The semantic purpose of a required diagram is fixed by the artifact contract.

A Mermaid syntax problem MUST be repaired within the required diagram type. Never change the diagram type merely because another Mermaid grammar is easier to generate.

Canonical mapping:

Required artifactRequired semantic representationAllowed Mermaid form
System Contextsystem/external-boundary relationshipsgraph or flowchart
Component Architecturecomponents, layers, ownership, dependenciesgraph or flowchart
Primary Runtime Sequencetime-ordered calls and responsessequenceDiagram
Integration Boundariessystem-to-external-system boundaries and dependenciesgraph or flowchart
State / Persistence Lifecyclestate transitions, ownership, persistence lifecyclestateDiagram-v2 or flowchart, chosen according to the evidence

Preservation rule

If the requested artifact is Component Architecture, it MUST remain a component/dependency graph. For example, this is incorrect repair behavior:

Component Architecture has invalid graph syntax
→ convert the artifact to sequenceDiagram

The correct behavior is:

Component Architecture has invalid graph syntax
→ retain graph/flowchart
→ repair only the invalid graph connectors/labels

Likewise:

Primary Runtime Sequence

must remain a sequence diagram and MUST NOT be converted into a component graph merely to avoid sequence syntax.

Semantic self-check

Before persisting a mandatory diagram, verify both:

  1. Grammar correctness — connectors and declarations belong to the selected Mermaid grammar.
  2. Semantic correctness — the selected Mermaid diagram type matches the purpose of the required artifact.

A syntactically valid diagram with the wrong semantic type MUST NOT satisfy the diagram quality gate.

For Component Architecture specifically, the diagram should primarily communicate:

  • architectural layers or subsystems;
  • component responsibility boundaries;
  • dependency direction;
  • important interfaces/adapters;
  • relevant external dependencies.

Method names may label relationships when useful, but the artifact must remain an architectural relationship graph rather than becoming a chronological call sequence.

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.