agentleFS
Destynova2Destynova2/cli-code-skills/cli-forge-lld/SKILL.md

cli-forge-lld

Skill5 starsChanged 8 months agoMITView on GitHub

Generate a Low-Level Design (LLD) document for a software component or service. Use when the user mentions 'LLD', 'low-level design', 'detailed design', 'class diagram', 'sequence diagram', 'API spec', 'database schema', 'component design', 'module design', 'STRIDE', 'threat model', or asks for detailed technical design of a specific service/component. Produces C4 L3-L4 diagrams, class/sequence/state diagrams, API contracts, DB schemas, error handling, and testability design. Do NOT use for system-level architecture — use cli-forge-hld instead.

1 other project uses a version of this, 1 of them edited.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    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. Very specific:

    Check if an HLD exists in the project (docs/*hld*, docs/*architecture*, docs/*design*)

    line 62
  2. Distinctive:

    If yes: identify which HLD container(s) this LLD covers

    line 63
  3. Distinctive:

    If no: note that this LLD is standalone and may need an HLD later

    line 64
  4. Distinctive:

    Read existing code if available:

    line 68
  5. Distinctive:

    Diagram > prose: If the class diagram already shows the relationships, don't re-explain them in text

    line 122
  6. Distinctive:

    Ask: "Would a developer make a wrong implementation choice without this section?" If no, cut it

    line 123
  7. Very specific:

    Read references/sections.md for full section templates with Mermaid examples.

    line 129
  8. Very specific:

    If you're drawing system context or estimating capacity, you've drifted into HLD territory.

    line 175
  9. Very specific:

    Read references/scoring.md for the full DCI-LLD formula, 12 checklist items with weights, thresholds, and derived metrics.

    line 181
  10. Very specific:

    Read references/anti-patterns.md for the 9 anti-patterns table with descriptions and fixes.

    line 185

≈ “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

Optimization: This skill uses on-demand loading. Heavy content lives in references/ and is loaded only when needed.

Language rule: Skill instructions are written in English. When generating user-facing output, detect the project's primary language (from README, comments, docs, commit messages) and produce the document in that language. If the project is bilingual, ask the user which language to use before proceeding.

Diacritics rule: When the chosen output language uses diacritics (French, Spanish, Portuguese, etc.), render them correctly — including on capitals (É, À, Ç, Ô…). Never strip accents to ASCII: write "sécurité" not "securite", "Rôle" not "Role". ASCII-flattened French is a defect, not a style.

Writing style: Favor clarity — short sentences, one idea per sentence, plain words. A metaphor only when it clarifies. Keep one consistent register (impersonal/infinitive for operational docs). Separate narrative prose, meant to make the reader understand, from telegraphic content (tables, commands, checklists) which stays terse for action.

No fabricated output: Never invent command output, console captures, API responses, metrics, or logs. When real output is needed, emit a clearly-marked placeholder (🚧 "replace with a real capture"), never plausible-but-fake text presented as real.

Forge LLD — Low-Level / Detailed Design

Translate an HLD's "what" into the "how" — detailed enough that a developer can implement without ambiguity. (Robert C. Martin, Clean Architecture)

Core Principles

  1. Mitosis — the document grows only the sections the component actually needs. A stateless function doesn't need a state machine. A read-only service doesn't need a migration plan. Kill empty sections, don't fill them with boilerplate
  2. Implementable precision — every included section must be specific enough to code from. No hand-waving
  3. Contract-first — define API contracts and interfaces before internals
  4. SOLID by default — design visible in class diagrams must respect SOLID; flag violations explicitly
  5. Patterns justified — only document a pattern when its use is non-obvious from reading the code
  6. KISS — one clear diagram beats two pages of prose. One code example beats three paragraphs of explanation. Readers are developers — they scan for interfaces, schemas, and contracts
  7. Gotchas — read ../gotchas.md before producing output to avoid known mistakes

Workflow

Step 1 — Identify scope

SignalOutput
"LLD", "low-level design", "detailed design"Full LLD for a component/service
"class diagram", "module design"Class/module design section only
"API spec", "contract", "OpenAPI"API contract section only
"DB schema", "database design", "ER diagram"Database schema section only
"sequence diagram", "flow"Sequence diagram for a specific flow
"STRIDE", "threat model"Security design section only
"state machine", "lifecycle"State machine section only

Step 2 — Locate the HLD anchor

The LLD must reference its parent HLD:

  1. Check if an HLD exists in the project (docs/*hld*, docs/*architecture*, docs/*design*)
  2. If yes: identify which HLD container(s) this LLD covers
  3. If no: note that this LLD is standalone and may need an HLD later

Step 3 — Gather implementation context

Read existing code if available:

  • Source files for the component (understand current structure)
  • Cargo.toml / package.json (dependencies, features)
  • Config files (understand runtime configuration)
  • Existing tests (understand testing approach)
  • CI pipeline (understand deployment constraints)

Step 4 — Size the document (Mitosis)

Determine the component's complexity tier. The tier decides which sections to include.

Detect the tier from signals:

SignalTier
Pure function, utility module, single-file componentS
Single service with DB, one domain conceptM
Service with external deps, multiple domain concepts, async flowsL
Complex service: multi-aggregate, saga, high concurrency, regulatedXL

Section inclusion matrix:

#SectionSMLXL
1Overview & HLD AnchorYesYesYesYes
2Component Architecture (C4 L3)—YesYesYes
3Tactical Domain Model—If DDDYesYes
4Class/Module DesignKey interfacesYesYesYes
5API ContractsIf API existsYesYesYes
6Database SchemaIf persistenceYesYesYes
7Sequence DiagramsMain flow onlyHappy + errorAll criticalAll
8State Machines—If >2 statesYesYes
9Error Handling & ResilienceError codes onlyYesYesYes
10Concurrency Design——If shared stateYes
11Caching Strategy—If cache existsYesYes
12Component-Level Security (STRIDE)—Input validationYesYes
13Testability Design—DI points onlyYesYes
14Configuration & Feature Flags—If non-trivialYesYes
15Micro-ADRs—If non-obviousYesYes
16Migration Plan——If brownfieldIf brownfield

Target document size:

TierPagesSectionsDiagrams
S1-33-51-2
M4-87-103-5
L8-1512-145-8
XL12-20All 168+

Rules:

  • Never include an empty section. Omit entirely — don't write "N/A" or "Not applicable"
  • Merge small sections for tier S. Class Design + API Contract + DB Schema can be one "Implementation" section
  • State the tier at the top so readers calibrate their expectations
  • Diagram > prose. If the class diagram already shows the relationships, don't re-explain them in text
  • Ask: "Would a developer make a wrong implementation choice without this section?" If no, cut it

Step 5 — Write the LLD

Only include sections selected by the mitosis matrix in Step 4. For tier S, merge related sections freely.

Read references/sections.md for full section templates with Mermaid examples. Only include sections selected by the mitosis matrix.


LLD Document Structure

# [Component/Service Name] — Low-Level Design

## 1. Overview & HLD Anchor
## 2. Component Architecture (C4 Level 3)
## 3. Tactical Domain Model
## 4. Class/Module Design
## 5. API Contracts
## 6. Database Schema
## 7. Sequence Diagrams (Critical Flows)
## 8. State Machines
## 9. Error Handling & Resilience
## 10. Concurrency Design
## 11. Caching Strategy
## 12. Component-Level Security (STRIDE)
## 13. Testability Design
## 14. Configuration & Feature Flags
## 15. Micro-ADRs
## 16. Migration Plan

HLD vs LLD Boundary

In LLDNOT in LLD (→ HLD)
C4 Level 3-4 diagramsC4 Level 1-2 diagrams
Full API contracts (OpenAPI)API surface list
Table schemas with indexesEntity-relationship sketch
Class diagrams with methods, SOLIDContainer diagram
Circuit breaker config values"We use circuit breakers"
Component-level STRIDE (SQLi, IDOR, input validation)System-level trust boundaries, security policies
Retry/backoff configurationFailure mode categories
Migration scripts / phases"We'll migrate data"
Tactical DDD (aggregates, entities, value objects)Strategic DDD (bounded contexts, context maps)
Concurrency design (locks, channels, race conditions)Scalability strategy (horizontal, sharding)
Testability design (DI points, mock boundaries)Test strategy overview
Cache TTLs, invalidation patterns"We need caching for hot data"

If you're drawing system context or estimating capacity, you've drifted into HLD territory. Stop and suggest the user invoke /cli-forge-hld.


Quality Scoring

Read references/scoring.md for the full DCI-LLD formula, 12 checklist items with weights, thresholds, and derived metrics.

Anti-Patterns

Read references/anti-patterns.md for the 9 anti-patterns table with descriptions and fixes.


Review Checklist

All tiers: Tier stated | HLD referenced | Interfaces defined | Mermaid syntax | No empty sections | No HLD-level content

M+: C4 L3 | API contracts (schemas + errors) | DB schema (ER + indexes) | Sequence diagrams (happy + error) | Error taxonomy

L+: Class diagram (SOLID) | State machines | STRIDE | Testability (DI + mocks) | Micro-ADRs

XL: Concurrency | Tactical DDD | Migration plan (if brownfield)

Size: S: 1-3p | M: 4-8p | L: 8-15p | XL: 12-20p — no section exists just because it's in the template


Dynamic Handoffs

Condition detectedRecommendWhy
LLD reveals security threats (STRIDE)/cli-audit-code on affected componentsC9 security check
API contracts defined/cli-audit-driftBootstrap CONTRACTS.md from the LLD
Component has complex state machine/cli-forge-schemaGenerate state diagram
PostgreSQL/SQLx schema, transactions, or brownfield migration carry business invariants/cli-forge-dataProduce the database decision, concurrency proof, and safe migration plan

Rule: Recommend, don't auto-execute.

Integration with other cli-* skills

SkillRelationship
cli-forge-hldProvides the container architecture that LLD zooms into
cli-forge-schemaCan generate the Mermaid diagrams used in the LLD
cli-audit-codeValidates the implementation matches the LLD design
cli-audit-testValidates test coverage matches the testability design
cli-cycleCalls cli-forge-lld as part of full project review
cli-forge-dataDeepens sections 6, 8, 10, and 16 for PostgreSQL/SQLx persistence

Reference Sources

Books: Clean Architecture (Martin), DDD (Evans), IDDD (Vernon), Learning DDD (Khononov), PEAA (Fowler), Design Patterns (GoF), Release It! (Nygard), Domain Modeling Made Functional (Wlaschin), Working with Legacy Code (Feathers)

Templates: C4 Model, arc42, MADR, French DAT, awesome-low-level-design, STRIDE

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.