skills/design-forces/SKILL.md
Surface design forces and lay out the option space — including framework defaults, scaffolds, and deferring — before committing to Clean Architecture, DDD, or any heavier pattern. Produces a Design Analysis Memo at the start of /write, /refactor, or non-trivial /fix. Make sure to use this skill whenever the user starts a non-trivial feature, restructures code, or asks "do we really need Clean Architecture / DDD / pattern X here".
npx skillsauth add elct9620/ai-coding-skills design-forcesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Principles (KISS, SOLID, DRY, YAGNI, fail-fast) apply underneath every option. The memo operates one layer above them.
| Condition | Pass | |-----------|------| | Architectural commitment on the table | Question of the form "do we use CA / DDD / pattern X / scaffold?" is live | | Non-trivial scope | Feature crosses files or layers, or replaces existing behaviour | | Surrounding code lacks a clear convention | Legacy area or framework-inconsistent code | | Risk-bearing change | Auth, payments, data integrity, external API, migration |
Apply when: Any condition passes.
A short note for the developer: forces pulling on the decision, 4–6 options drawn from this codebase, framework, and wider repertoire (framework defaults, scaffolds, internal libraries, defer, spike, plus structural choices), trade-offs, and a soft recommendation with the conditions under which it would change. The developer reads and decides; other skills activate based on the chosen direction.
| Force | The question this lens asks | |-------|------------------------------| | Delivery pressure | Is the cost of deeper investment recoverable in the time we have? | | Rule complexity | Are the rules thick enough to deserve explicit modelling? | | Change rate | Is paying upfront for flexibility cheaper than paying later for rework? | | Team and language fragmentation | Will more than one team or role describe this in their own words? | | Blast radius | What breaks if this is wrong, and how visibly? | | Code maturity | Does the surrounding code need preparing before this lands cleanly? |
Look through every lens. "Doesn't really apply here" is a fine answer, as long as the lens was consulted.
| Source | What to find |
|--------|--------------|
| docs/architecture.md Patterns section | Lightweight pattern entries the team has already chosen |
| docs/decisions/ (or docs/adr/) | Heavier ADRs when present |
| docs/architecture.md body | Style declarations (Pure CA, CA+DDD, conventional Rails) |
For each recorded pattern overlapping the task's surface, ask: does the situation still match, and have any revisit triggers fired? If a recorded pattern fits and triggers are quiet, write a Confirming Memo and stop. Otherwise continue.
Framework posture is the priority signal — the idiomatic option is a first-class candidate, not a baseline to bypass.
| Signal | Source | Maps to |
|--------|--------|---------|
| Framework + idiom | Gemfile, package.json, pyproject.toml, go.mod; app/services/, pages/, cmd/ | Framework posture, conventional option |
| File age & churn | git log --since='3 months ago' -- <paths> | Change rate, code maturity |
| Contributors | git shortlog -sn --since='6 months ago' | Team fragmentation |
| Test presence | find . -name '*_test.*' -o -name '*.spec.*' | Code maturity |
| Domain hints in spec | "multi-step", "workflow", "invariant", "approval" | Rule complexity |
| Risk hints in spec | "payment", "auth", "PII", "audit" | Blast radius |
| Repetition signal | 2+ similar structures already hand-written; a third coming | Scaffold/generator as candidate |
Use signals first. Reach for questions only for gaps.
| Question | Pins | |----------|------| | When does this need to ship? | Delivery pressure | | How likely is this spec to change in the next 6 months? | Change rate | | Will more than one team or role describe this in their own words? | Team fragmentation | | What breaks for users if this is wrong? | Blast radius | | Is this likely the first of several similar features? | Scaffold/generator candidacy | | How comfortable is the team deviating from the framework's idiomatic shape? | Realism of non-idiomatic options |
When a signal strongly implies an answer, state the inference and move on.
Aim for 4–6, grounded in this project. Include:
Keep it under one screen.
# Design Analysis: <task name>
## Context
<2-3 sentences: what is being built, in what codebase, with what framework.>
## Existing patterns considered
<For each overlapping recorded pattern: applies cleanly / applies with caveats / no longer fits because <trigger>. Or: "None — fresh decision.">
## Forces in play
- Delivery pressure: <level — evidence>
- Rule complexity: <…>
- Change rate: <…>
- Team fragmentation: <…>
- Blast radius: <…>
- Code maturity: <…>
## Options on the table
1. **<Concrete option name>** — <shape in one sentence>; Pros: <…>; Cons: <…>
2. ...
## Trade-offs
<Strongest tension. Which forces pull which way. Cost of being wrong in each direction.>
## Soft recommendation
<Lean toward Option N because <forces and grounding>. Would change to Option M if <observable condition>.>
## Worth confirming before committing
<1–2 questions whose answers would meaningfully change the recommendation.>
## Recording (if adopted)
<If the option is likely to recur, propose a Patterns-section entry (see format below). For a one-off, write "One-off — no recording." For a large-blast-radius / multi-team / hard-to-reverse decision, propose an ADR in `docs/decisions/` instead.>
When Step 0 finds a recorded pattern that fits cleanly:
# Design Analysis: <task name> (confirming existing pattern)
Falls under recorded pattern **<name>** in docs/architecture.md.
## Forces re-check
- <Each force in one line, confirming the situation still matches.>
- <If any revisit trigger has fired, switch back to the full memo.>
## Plan
Apply the pattern as recorded. Canonical example: <file path>.
## Anything unusual
<One sentence on what differs (if anything) and how to handle it. "Standard application." is a valid answer.>
Lives in docs/architecture.md. Each entry is ~6–10 lines.
## Patterns
### <Pattern name in this project's vocabulary>
- **When to apply**: <situation in this project, 1-2 sentences>
- **Shape**: <structural commitment — e.g. "service object + audit invariant + role check at the use case boundary">
- **Canonical example**: <file path>
- **Forces this resolves**: <dominant forces that selected this>
- **Revisit if**: <observable condition that would prompt reconsideration>
An entry earns its place when:
For decisions large enough to need full context, alternatives discussion, and explicit acceptance — large blast radius, multi-team, hard to reverse — write an ADR in docs/decisions/ instead.
| Criterion | Pass | |-----------|------| | All six lenses consulted | Each force has a line, evidenced from a signal or an answer | | Recorded patterns considered | Step 0 result appears in the memo | | Framework posture named | The idiomatic option appears as a real candidate, in the framework's own vocabulary | | Option space deliberately wide | At least one "do less" option and, where plausible, one meta-level option | | Grounded in this codebase | Option names refer to actual directories, conventions, or libraries here | | Soft recommendation conditional | Includes the observable conditions that would change it | | Principles as baseline | Memo treats KISS / SOLID / DRY / YAGNI as baseline underneath every option |
| Criterion | Pass | |-----------|------| | Time budget | Diagnosis completes in a single short turn | | Signal-first | Codebase and framework signals consulted before user questions | | Question budget | ≤3 questions asked of the user | | Memo length | Body fits under one screen |
| Criterion | Pass | |-----------|------| | Clear next step | Memo ends with the developer's next move — confirm, redirect, or sanity-check named items | | Recording proposed when appropriate | If the option will recur, a Patterns-section entry is drafted; if heavy, an ADR is named |
development
Plan how a system is structured — which layers, modules, or contexts exist and how code is laid out — driven by the forces at play, not by a fixed pattern. The default is to add no extra structure; structure is introduced only when complexity calls for it, and the chosen shape (Clean Architecture, DDD, DCI, or another) is judged in the moment. Use this skill when following a recorded structure in docs/architecture.md, or when deciding the structural shape for a non-trivial feature, a new module, or a restructuring — especially after a design-forces memo recommends a layered or partitioned structure.
development
Write tests using TDD (Red-Green-Refactor) and AAA pattern. Use for every new feature, behavior change, or bug fix. Covers unit, integration, and E2E test selection. Make sure to use this skill whenever the user asks to add tests, fix a bug (tests should come first), implement a feature with test coverage, or asks about what kind of tests to write — even for small one-line changes or trivial-looking fixes.
development
Prevent security vulnerabilities through threat modeling, trust boundary analysis, and defense in depth. Use when writing code that crosses trust boundaries, handles authentication or authorization, processes external input, manages secrets, or stores sensitive data. Make sure to use this skill whenever the user works on login flows, processes data from external sources, builds interfaces between systems, manages credentials, or writes code that moves data across trust zones — even for seemingly simple changes like accepting a new parameter or calling an external service.
development
Design database schemas and API contracts at system boundaries. Use when creating or modifying database tables, API endpoints, or data serialization formats. Make sure to use this skill whenever the user adds database migrations, designs REST/GraphQL APIs, creates DTOs, defines request/response shapes, or works on data serialization — even for adding a single column or endpoint.