forgecommandline 0.8.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- forgecli/__init__.py +2 -0
- forgecli/ads.py +322 -0
- forgecli/agent.py +1093 -0
- forgecli/art.py +574 -0
- forgecli/attach.py +246 -0
- forgecli/brief.py +215 -0
- forgecli/browsercheck.py +99 -0
- forgecli/checkpoints.py +81 -0
- forgecli/city.py +833 -0
- forgecli/cli.py +1668 -0
- forgecli/config.py +194 -0
- forgecli/courier.py +177 -0
- forgecli/courier_data.py +164 -0
- forgecli/courier_hd.py +431 -0
- forgecli/courier_hd_data.bin +0 -0
- forgecli/courier_hd_data.py +19 -0
- forgecli/ghlogin.py +76 -0
- forgecli/github.py +54 -0
- forgecli/guards.py +403 -0
- forgecli/hooks.py +50 -0
- forgecli/httpapi.py +434 -0
- forgecli/images.py +110 -0
- forgecli/keys.py +152 -0
- forgecli/keyvault.py +320 -0
- forgecli/mcp.py +674 -0
- forgecli/memory.py +42 -0
- forgecli/openapi.py +331 -0
- forgecli/parallel.py +308 -0
- forgecli/prices.py +72 -0
- forgecli/procs.py +144 -0
- forgecli/providers.py +758 -0
- forgecli/quality.py +192 -0
- forgecli/repomap.py +78 -0
- forgecli/roster.py +227 -0
- forgecli/safety.py +93 -0
- forgecli/sandbox.py +83 -0
- forgecli/sessions.py +97 -0
- forgecli/skills.py +446 -0
- forgecli/tools.py +1184 -0
- forgecli/ui.py +860 -0
- forgecli/worktrees.py +79 -0
- forgecommandline-0.8.0.data/data/skills/commit/SKILL.md +14 -0
- forgecommandline-0.8.0.data/data/skills/debug/SKILL.md +17 -0
- forgecommandline-0.8.0.data/data/skills/explain/SKILL.md +14 -0
- forgecommandline-0.8.0.data/data/skills/init/SKILL.md +19 -0
- forgecommandline-0.8.0.data/data/skills/library/LICENSES/agent-skills-MIT.txt +21 -0
- forgecommandline-0.8.0.data/data/skills/library/LICENSES/wondelai-MIT.txt +23 -0
- forgecommandline-0.8.0.data/data/skills/library/README.md +9 -0
- forgecommandline-0.8.0.data/data/skills/library/_references/accessibility-checklist.md +160 -0
- forgecommandline-0.8.0.data/data/skills/library/_references/definition-of-done.md +67 -0
- forgecommandline-0.8.0.data/data/skills/library/_references/observability-checklist.md +92 -0
- forgecommandline-0.8.0.data/data/skills/library/_references/orchestration-patterns.md +370 -0
- forgecommandline-0.8.0.data/data/skills/library/_references/performance-checklist.md +238 -0
- forgecommandline-0.8.0.data/data/skills/library/_references/security-checklist.md +248 -0
- forgecommandline-0.8.0.data/data/skills/library/_references/testing-patterns.md +235 -0
- forgecommandline-0.8.0.data/data/skills/library/api-and-interface-design/SKILL.md +367 -0
- forgecommandline-0.8.0.data/data/skills/library/architecture-optimization/SKILL.md +279 -0
- forgecommandline-0.8.0.data/data/skills/library/architecture-optimization/references/artifact-templates.md +157 -0
- forgecommandline-0.8.0.data/data/skills/library/architecture-optimization/references/methods.md +87 -0
- forgecommandline-0.8.0.data/data/skills/library/awwwards-tier-web-application/SKILL.md +877 -0
- forgecommandline-0.8.0.data/data/skills/library/browser-testing-with-devtools/SKILL.md +317 -0
- forgecommandline-0.8.0.data/data/skills/library/ci-cd-and-automation/SKILL.md +390 -0
- forgecommandline-0.8.0.data/data/skills/library/code-review-and-quality/SKILL.md +398 -0
- forgecommandline-0.8.0.data/data/skills/library/code-simplification/SKILL.md +331 -0
- forgecommandline-0.8.0.data/data/skills/library/constraint-driven-development/SKILL.md +311 -0
- forgecommandline-0.8.0.data/data/skills/library/constraint-driven-development/references/floor-guard.md +182 -0
- forgecommandline-0.8.0.data/data/skills/library/context-engineering/SKILL.md +353 -0
- forgecommandline-0.8.0.data/data/skills/library/debugging-and-error-recovery/SKILL.md +300 -0
- forgecommandline-0.8.0.data/data/skills/library/deprecation-and-migration/SKILL.md +247 -0
- forgecommandline-0.8.0.data/data/skills/library/documentation-and-adrs/SKILL.md +297 -0
- forgecommandline-0.8.0.data/data/skills/library/doubt-driven-development/SKILL.md +243 -0
- forgecommandline-0.8.0.data/data/skills/library/frontend-ui-engineering/SKILL.md +340 -0
- forgecommandline-0.8.0.data/data/skills/library/git-workflow-and-versioning/SKILL.md +355 -0
- forgecommandline-0.8.0.data/data/skills/library/idea-refine/SKILL.md +193 -0
- forgecommandline-0.8.0.data/data/skills/library/idea-refine/examples.md +238 -0
- forgecommandline-0.8.0.data/data/skills/library/idea-refine/frameworks.md +99 -0
- forgecommandline-0.8.0.data/data/skills/library/idea-refine/refinement-criteria.md +113 -0
- forgecommandline-0.8.0.data/data/skills/library/idea-refine/scripts/idea-refine.sh +15 -0
- forgecommandline-0.8.0.data/data/skills/library/improve-code-quality/SKILL.md +275 -0
- forgecommandline-0.8.0.data/data/skills/library/improve-code-quality/references/artifact-templates.md +101 -0
- forgecommandline-0.8.0.data/data/skills/library/incremental-implementation/SKILL.md +249 -0
- forgecommandline-0.8.0.data/data/skills/library/interview-me/SKILL.md +235 -0
- forgecommandline-0.8.0.data/data/skills/library/observability-and-instrumentation/SKILL.md +238 -0
- forgecommandline-0.8.0.data/data/skills/library/performance-optimization/SKILL.md +267 -0
- forgecommandline-0.8.0.data/data/skills/library/performance-optimization/references/optimization-patterns.md +250 -0
- forgecommandline-0.8.0.data/data/skills/library/planning-and-task-breakdown/SKILL.md +257 -0
- forgecommandline-0.8.0.data/data/skills/library/remove-technical-debt/SKILL.md +203 -0
- forgecommandline-0.8.0.data/data/skills/library/remove-technical-debt/references/artifact-templates.md +79 -0
- forgecommandline-0.8.0.data/data/skills/library/security-and-hardening/SKILL.md +216 -0
- forgecommandline-0.8.0.data/data/skills/library/security-and-hardening/references/hardening-patterns.md +324 -0
- forgecommandline-0.8.0.data/data/skills/library/shipping-and-launch/SKILL.md +336 -0
- forgecommandline-0.8.0.data/data/skills/library/source-driven-development/SKILL.md +216 -0
- forgecommandline-0.8.0.data/data/skills/library/spec-driven-development/SKILL.md +259 -0
- forgecommandline-0.8.0.data/data/skills/library/system-design/SKILL.md +207 -0
- forgecommandline-0.8.0.data/data/skills/library/system-design/references/building-blocks.md +272 -0
- forgecommandline-0.8.0.data/data/skills/library/system-design/references/common-designs.md +257 -0
- forgecommandline-0.8.0.data/data/skills/library/system-design/references/database-scaling.md +295 -0
- forgecommandline-0.8.0.data/data/skills/library/system-design/references/estimation-numbers.md +250 -0
- forgecommandline-0.8.0.data/data/skills/library/system-design/references/four-step-process.md +286 -0
- forgecommandline-0.8.0.data/data/skills/library/system-design/references/reliability-operations.md +373 -0
- forgecommandline-0.8.0.data/data/skills/library/test-driven-development/SKILL.md +398 -0
- forgecommandline-0.8.0.data/data/skills/library/using-agent-skills/SKILL.md +192 -0
- forgecommandline-0.8.0.data/data/skills/review/SKILL.md +16 -0
- forgecommandline-0.8.0.data/data/skills/run/SKILL.md +17 -0
- forgecommandline-0.8.0.data/data/skills/security-review/SKILL.md +20 -0
- forgecommandline-0.8.0.data/data/skills/simplify/SKILL.md +18 -0
- forgecommandline-0.8.0.data/data/skills/test/SKILL.md +16 -0
- forgecommandline-0.8.0.data/data/skills/web-build/SKILL.md +25 -0
- forgecommandline-0.8.0.dist-info/METADATA +357 -0
- forgecommandline-0.8.0.dist-info/RECORD +113 -0
- forgecommandline-0.8.0.dist-info/WHEEL +5 -0
- forgecommandline-0.8.0.dist-info/entry_points.txt +2 -0
- forgecommandline-0.8.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
# This script helps initialize the ideas directory for the idea-refine skill.
|
|
5
|
+
|
|
6
|
+
IDEAS_DIR="docs/ideas"
|
|
7
|
+
|
|
8
|
+
if [ ! -d "$IDEAS_DIR" ]; then
|
|
9
|
+
mkdir -p "$IDEAS_DIR"
|
|
10
|
+
echo "Created directory: $IDEAS_DIR" >&2
|
|
11
|
+
else
|
|
12
|
+
echo "Directory already exists: $IDEAS_DIR" >&2
|
|
13
|
+
fi
|
|
14
|
+
|
|
15
|
+
echo "{\"status\": \"ready\", \"directory\": \"$IDEAS_DIR\"}"
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: improve-code-quality
|
|
3
|
+
description: 'Guided journey from a working-but-untested vibe-coded prototype to a production-ready product with tests, clean structure, a business-rules boundary, and resilience at scale. Orchestrates nine skills phase by phase - working-with-legacy-code, clean-code, refactoring-patterns, software-design-philosophy, clean-architecture, pragmatic-programmer, release-it, system-design, ddia-systems - asking the user questions at every decision point and recording results in the project docs/ folder (TESTING.md, TECH-DEBT.md, IMPROVE-CODE-QUALITY-PLAN.md) so the journey resumes across sessions. Use when the user wants to harden an AI-generated prototype, add tests before refactoring, make code safe to change, or says ''this works on my machine but I am scared to touch it''. For an aged codebase, remove-technical-debt; for greenfield structure, design-code-architecture; for a product and UX pass, improve-app; to optimize speed and structure, architecture-optimization. For one framework in isolation, invoke that skill directly.'
|
|
4
|
+
license: MIT
|
|
5
|
+
metadata:
|
|
6
|
+
author: wondelai
|
|
7
|
+
version: "1.0.2"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Improve Code Quality
|
|
11
|
+
|
|
12
|
+
Turn a working-but-untested vibe-coded prototype into a product you can ship and operate. This is an
|
|
13
|
+
interactive, resumable journey of nine phases: the agent asks before every decision and records the
|
|
14
|
+
outcome in your project's `docs/` folder, so you can stop after any phase and pick up later. A
|
|
15
|
+
week-old prototype is already legacy code — so the first move is a safety net, and every phase after
|
|
16
|
+
it is verifiable because of that net.
|
|
17
|
+
|
|
18
|
+
## Core Principle
|
|
19
|
+
|
|
20
|
+
**A week-old untested prototype is already legacy code: flip tactical to strategic — safety net
|
|
21
|
+
first, then readability, structure, and production hardening in order.** This skill sequences the
|
|
22
|
+
phases, asks the decision questions, and records every choice in `docs/`. The constituent skills
|
|
23
|
+
carry the method — invoke them rather than improvising their frameworks. Skipping ahead (refactoring
|
|
24
|
+
before tests, scaling before sizing) is the exact failure mode this ordering exists to prevent.
|
|
25
|
+
|
|
26
|
+
## Journey Map
|
|
27
|
+
|
|
28
|
+
| Phase | Skill | Question it answers | Artifact |
|
|
29
|
+
|---|---|---|---|
|
|
30
|
+
| 1 | working-with-legacy-code | Can I change this code without breaking it unknowingly? | Creates docs/TESTING.md + docs/TECH-DEBT.md — GATE |
|
|
31
|
+
| 2 | clean-code | Is this readable to the next person (and agent)? | Extends docs/TECH-DEBT.md |
|
|
32
|
+
| 3 | refactoring-patterns | Can I reshape structure without changing behavior? | Extends docs/TECH-DEBT.md |
|
|
33
|
+
| 4 | software-design-philosophy | Is complexity hidden behind deep modules? | Extends docs/TECH-DEBT.md |
|
|
34
|
+
| 5 | clean-architecture | Do business rules depend on the framework, or vice versa? | Extends docs/ARCHITECTURE.md |
|
|
35
|
+
| 6 | pragmatic-programmer | What habits keep it clean after we stop? | Extends docs/TECH-DEBT.md |
|
|
36
|
+
| 7 | release-it | Will it survive a hostile production? | Creates docs/RELIABILITY.md |
|
|
37
|
+
| 8 | system-design | Is it sized for the load we actually have? | Extends docs/ARCHITECTURE.md + docs/RELIABILITY.md |
|
|
38
|
+
| 9 | ddia-systems | Is the data layer correct and durable under concurrency? | Extends docs/ARCHITECTURE.md |
|
|
39
|
+
|
|
40
|
+
## Operating Rules
|
|
41
|
+
|
|
42
|
+
1. **Resume first.** Before anything else, read `docs/IMPROVE-CODE-QUALITY-PLAN.md` and every artifact in the Journey Map. If the tracker exists, summarize the journey state in 3-5 lines and ask which phase to enter. Done when the user has confirmed an entry point. A journey with a tracker is resumed, never restarted.
|
|
43
|
+
2. **Intake on first run only.** No tracker: run the Intake below, then create `docs/IMPROVE-CODE-QUALITY-PLAN.md` with every phase statused `pending | in-progress | awaiting-evidence | done | deferred: reason | skipped: reason`. Done when the tracker exists and the user has confirmed the phase plan.
|
|
44
|
+
3. **Phase entry.** Announce: what the phase does, the decision it forces, the artifact it produces, rough effort. Offer proceed / skip / defer — phases marked GATE may be deferred, never skipped. Mark the phase `in-progress` on proceed. Done when the user chose.
|
|
45
|
+
4. **Skill invocation and fallback.** Load the phase's skill and use it: each phase's Invoke line names the skill by slug — use that skill to run the phase. If it is not available, offer: `npx skills add wondelai/skills/<slug> --global`. If the user declines, run the phase from its Brief — the minimum viable method. State which mode you are in.
|
|
46
|
+
5. **In-phase decisions.** Ask every question under "Decide with the user" — with concrete options and your recommendation. Record the choice in the tracker's Key Decisions. A decision made silently is a defect.
|
|
47
|
+
6. **Phase exit.** Present the draft artifact content for sign-off before writing. On approval: write or extend the docs/ files, update the tracker (status, Key Decisions, Next Actions). Done when the files are written and the phase row shows `done`.
|
|
48
|
+
7. **Artifact discipline.** Read before writing; create a file only if missing, otherwise extend — add or update your sections, preserve everyone else's. Files are UPPERCASE in `docs/`. Every recommendation lands as a checkbox or a table row with owner and priority. See [references/artifact-templates.md](references/artifact-templates.md) when creating a docs/ file for the first time — create it from the full skeleton (all section headings), then fill the sections your phase names.
|
|
49
|
+
8. **Phase 1 is a gate; commits stay single-purpose.** No phase touches code absent from the Safety Net Map — pin it first (absent means not listed under Pinned behaviors; entries in the Gaps column are off-limits too). Structural and behavioral changes never share a commit: refactor with tests green in a structure-only commit, then change behavior in its own commit. A test that goes red mid-refactoring means revert and retry in smaller steps, not debug. Safety-net test additions and docs/ updates are single-purpose commits of their own.
|
|
50
|
+
|
|
51
|
+
## Intake
|
|
52
|
+
|
|
53
|
+
Ask these before creating the tracker:
|
|
54
|
+
|
|
55
|
+
1. What does the app do, and what is the worst thing that happens if it breaks? (frames risk and sets phase priority)
|
|
56
|
+
2. Which module are you changing next, and which has the highest churn (`git log`) or is core domain? (picks the Phase 1 starting module — the three-axis heuristic)
|
|
57
|
+
3. Do any automated tests exist today, and does a test command run green? (scopes the Phase 1 safety net)
|
|
58
|
+
4. What is the stack — framework, ORM, database? (gates Phases 5 and 9 — the boundary and data decisions)
|
|
59
|
+
5. Is this in production with real user data, and roughly how many active users or requests? (gates Phases 7-9 — resilience is requirements-driven)
|
|
60
|
+
6. What outbound dependencies does it call — third-party APIs, payments, email, queues? (gates Phase 7 — the integration-point audit)
|
|
61
|
+
7. How much of the journey do you want now? (Phases 1-3 before real users; Phase 7 before launch; Phases 8-9 track actual growth)
|
|
62
|
+
|
|
63
|
+
Phase-skip heuristics: skip Phases 8-9 when real load is far below any scaling threshold (start with requirements, not solutions — don't build for 50k users while at 50). Phase 7 is not optional once real users exist — timeouts and a circuit breaker are table stakes even at low traffic (it may stay `deferred: reason`, never `skipped`). Never skip Phase 1; it is the gate. Then create the tracker from the template and confirm the plan.
|
|
64
|
+
|
|
65
|
+
Done when `docs/IMPROVE-CODE-QUALITY-PLAN.md` exists with every phase statused and the user has confirmed the plan.
|
|
66
|
+
|
|
67
|
+
## Phases
|
|
68
|
+
|
|
69
|
+
Phases run in the listed order — each assumes the previous phase's artifact exists. Any phase can be entered, skipped, or deferred per the Operating Rules, but Phase 1 gates them all: nothing downstream touches unpinned code.
|
|
70
|
+
|
|
71
|
+
### Phase 1 — Build the safety net (working-with-legacy-code) — GATE
|
|
72
|
+
|
|
73
|
+
**Purpose:** Pin current behavior at the change points so every later phase is verifiable. No phase may touch code absent from the Safety Net Map.
|
|
74
|
+
|
|
75
|
+
**Brief (fallback):** Legacy code is code without tests, so a week-old prototype qualifies. Cover and
|
|
76
|
+
modify, never edit and pray: identify change points, break inline dependencies with the
|
|
77
|
+
least-invasive seam (Parameterize Constructor with a production default; Extract and Override for one
|
|
78
|
+
buried call), then write characterization tests that photograph actual behavior — assert something
|
|
79
|
+
wrong, read the failure, pin the real value. When full coverage isn't feasible in time, Sprout/Wrap
|
|
80
|
+
the new code and track the untested host as debt.
|
|
81
|
+
|
|
82
|
+
**Invoke:** Use the `working-with-legacy-code` skill with the starting module chosen at intake. Ask for an effect
|
|
83
|
+
sketch from the entry method, the seams, and the smallest characterization-test set that pins current
|
|
84
|
+
signup / billing / core behavior.
|
|
85
|
+
|
|
86
|
+
**Decide with the user:** (1) Confirm the starting module by the three-axis heuristic — changing next, high churn, core domain. (2) Bugs found while characterizing: pin the wrong behavior and file it in the Debt Ledger, never silently fix — callers may depend on the quirk. Confirm the user accepts this.
|
|
87
|
+
|
|
88
|
+
**Artifact:** Create docs/TESTING.md with `## Test Strategy`, `## Safety Net Map` (module | pinned behaviors | test files | gaps), and `## Characterization Backlog`; create docs/TECH-DEBT.md with `## Debt Ledger` (item | location | type | risk | effort | priority | status) and `## Sprout / Wrap Register`. Update the tracker.
|
|
89
|
+
|
|
90
|
+
**Done when:** the target module's behavior is pinned, the suite runs green, both files exist, and Phase 1 shows `done` — only then are later phases unlocked.
|
|
91
|
+
|
|
92
|
+
### Phase 2 — Make the code readable (clean-code)
|
|
93
|
+
|
|
94
|
+
**Purpose:** Optimize for the reader — names, small single-purpose functions, safe error handling — now that changes are verifiable.
|
|
95
|
+
|
|
96
|
+
**Brief (fallback):** Code is read far more than written. Names reveal intent (`elapsedTimeInDays`,
|
|
97
|
+
not `d`); booleans read as predicates; functions do one thing at one level of abstraction with 0-2
|
|
98
|
+
arguments (a flag argument is two functions). Command-Query Separation: change state or return a
|
|
99
|
+
value, never both. Error handling: prefer exceptions to return codes, catch specific types, never
|
|
100
|
+
return or pass null (use an empty collection, Optional, or Null Object), and put operation + state
|
|
101
|
+
context in every thrown error.
|
|
102
|
+
|
|
103
|
+
**Invoke:** Use the `clean-code` skill with a target module. Ask for a 0-10 score across the six disciplines plus the top ten fixes in priority order, and an error-handling audit (bare catches, null returns, contextless errors).
|
|
104
|
+
|
|
105
|
+
**Decide with the user:** Which fixes to apply now versus log as debt, the naming / error-handling conventions the team adopts going forward, and whether the clean-code score becomes a CI gate.
|
|
106
|
+
|
|
107
|
+
**Artifact:** Extend docs/TECH-DEBT.md: add rows to `## Smell Inventory` (smell | location | refactoring | status) for each name / function / error smell, and record the agreed rules under `## Adopted Conventions`. Update the tracker.
|
|
108
|
+
|
|
109
|
+
**Done when:** the module scores 8+ or every gap below 8 is a Smell Inventory row with a fix, conventions are recorded, and the Phase 1 tests still pass.
|
|
110
|
+
|
|
111
|
+
### Phase 3 — Apply named refactorings (refactoring-patterns)
|
|
112
|
+
|
|
113
|
+
**Purpose:** Turn "clean it up" into named, behavior-preserving transformations executed in small steps.
|
|
114
|
+
|
|
115
|
+
**Brief (fallback):** Each smell maps to a named refactoring. Extract Method is the workhorse — if
|
|
116
|
+
you would write a comment to explain a block, extract it and name it after the comment. Also Replace
|
|
117
|
+
Magic Number with Symbolic Constant, Replace Nested Conditional with Guard Clauses, Replace
|
|
118
|
+
Conditional with Polymorphism, Introduce Parameter Object. Workflow: tests green, one transformation,
|
|
119
|
+
tests green, commit; a red test means revert, not debug. Preparatory Refactoring (make the change
|
|
120
|
+
easy, then make the easy change) and the Rule of Three guard against premature abstraction.
|
|
121
|
+
|
|
122
|
+
**Invoke:** Use the `refactoring-patterns` skill with a smelly function and the Phase 1 tests. Ask it to name each smell, cite the transformation, and apply one at a time with tests run between each.
|
|
123
|
+
|
|
124
|
+
**Decide with the user:** Scope — which smells to address this pass, whether an upcoming feature warrants a Preparatory Refactoring at its insertion point first, and whether the refactored module joins the CI gate list in TESTING.md.
|
|
125
|
+
|
|
126
|
+
**Artifact:** Extend docs/TECH-DEBT.md `## Smell Inventory`: for each smell, record the named refactoring applied and its status. Update the tracker.
|
|
127
|
+
|
|
128
|
+
**Done when:** targeted smells show a named refactoring and `done` / `ticketed` status, tests are green, and structural changes landed in structure-only commits.
|
|
129
|
+
|
|
130
|
+
### Phase 4 — Reduce complexity with deep modules (software-design-philosophy)
|
|
131
|
+
|
|
132
|
+
**Purpose:** Fight the classitis an unsupervised agent creates — hide real machinery behind simple interfaces instead of multiplying shallow classes.
|
|
133
|
+
|
|
134
|
+
**Brief (fallback):** Complexity is the enemy; minimize what a module imposes on the rest of the
|
|
135
|
+
system. Module depth = functionality ÷ interface complexity; deep modules hide machinery behind small
|
|
136
|
+
interfaces, shallow ones don't (classitis). Merge shallow classes that always travel together and
|
|
137
|
+
share state. Watch information leakage (one decision reflected in many modules) and temporal
|
|
138
|
+
decomposition (organizing by order-of-execution, not by knowledge). This is the tactical→strategic
|
|
139
|
+
flip: invest 10-20% to keep the design clean.
|
|
140
|
+
|
|
141
|
+
**Invoke:** Use the `software-design-philosophy` skill with the module set touched so far. Ask which classes are shallow, where information leaks across boundaries, and how to consolidate into deeper modules with simpler interfaces.
|
|
142
|
+
|
|
143
|
+
**Decide with the user:** Which consolidations to make now versus defer, guarding against over-merging unrelated concerns.
|
|
144
|
+
|
|
145
|
+
**Artifact:** Extend docs/TECH-DEBT.md `## Smell Inventory` with classitis / shallow-module / information-leakage entries and the consolidation applied. Update the tracker.
|
|
146
|
+
|
|
147
|
+
**Done when:** each shallow-module cluster is consolidated or logged with a fix, interface count did not grow for the sake of "modularity", and tests are green.
|
|
148
|
+
|
|
149
|
+
### Phase 5 — Draw the architecture boundary (clean-architecture)
|
|
150
|
+
|
|
151
|
+
**Purpose:** Make the framework and database depend on the business rules, not the reverse.
|
|
152
|
+
|
|
153
|
+
**Brief (fallback):** The Dependency Rule: source dependencies point inward — Entities, then Use
|
|
154
|
+
Cases, then Interface Adapters, then Frameworks/Drivers; nothing inner names anything outer. The
|
|
155
|
+
database and web are details, plugins to your rules. Enforce with Dependency Inversion: a Use Case
|
|
156
|
+
owns a repository interface; the Postgres/Stripe implementation lives in an outer adapter. SOLID are
|
|
157
|
+
the mid-level tools. Microservices sharing one data model are a distributed monolith — apply the rule
|
|
158
|
+
inside the service first.
|
|
159
|
+
|
|
160
|
+
**Invoke:** Use the `clean-architecture` skill with the current module map and the stack from intake. Ask it to map the dependency graph, list every violation where business logic imports the ORM or framework, and show the extraction to framework-free Use Cases behind owned interfaces.
|
|
161
|
+
|
|
162
|
+
**Decide with the user:** How far to push the boundary this pass, which vendors (payments, storage) to wrap behind owned interfaces first, and whether any planned service split waits until the in-service boundary holds (avoid a distributed monolith).
|
|
163
|
+
|
|
164
|
+
**Artifact:** Extend docs/ARCHITECTURE.md: record layers and current violations under `## Layer Map & Dependency Rule` (violation | location | fix | status) and the boundary choices under `## Decision Log`. Update the tracker.
|
|
165
|
+
|
|
166
|
+
**Done when:** every Dependency Rule violation is a tracked row with a fix, at least the highest-risk vendor is wrapped, business-rule tests run with no framework, and tests are green.
|
|
167
|
+
|
|
168
|
+
### Phase 6 — Lock in the habits (pragmatic-programmer)
|
|
169
|
+
|
|
170
|
+
**Purpose:** Set the meta-principles that keep the codebase changeable after this journey ends.
|
|
171
|
+
|
|
172
|
+
**Brief (fallback):** DRY is about knowledge, not text — de-duplicate the same rule in two places
|
|
173
|
+
(validation on client and server), leave coincidental look-alikes alone. Orthogonality: changing one
|
|
174
|
+
component shouldn't affect another. Broken Window Theory: fix hacks immediately or board them up with
|
|
175
|
+
a tracked ticket — never an untracked `// TODO`. Reversibility: wrap third-party vendors behind your
|
|
176
|
+
own interfaces. Tracer bullets: build the next feature as one thin real end-to-end slice, not layer
|
|
177
|
+
by layer.
|
|
178
|
+
|
|
179
|
+
**Invoke:** Use the `pragmatic-programmer` skill across the codebase. Ask it to flag duplicated knowledge (ignoring coincidental duplication) and any broken windows or untracked TODOs that need boarding up.
|
|
180
|
+
|
|
181
|
+
**Decide with the user:** The debt budget per iteration and the broken-windows policy — what gets fixed now versus ticketed.
|
|
182
|
+
|
|
183
|
+
**Artifact:** Extend docs/TECH-DEBT.md: record duplicated-knowledge and broken-window items in `## Debt Ledger`, and the agreed policy under `## Debt Budget & Broken-Windows Policy` and `## Adopted Conventions`. Update the tracker.
|
|
184
|
+
|
|
185
|
+
**Done when:** duplicated-knowledge hits are ledgered or fixed, no untracked hacks remain, and the debt-budget policy is written down.
|
|
186
|
+
|
|
187
|
+
### Phase 7 — Make it survive production (release-it)
|
|
188
|
+
|
|
189
|
+
**Purpose:** Harden every integration point so a slow or failing dependency degrades gracefully instead of taking the whole app down.
|
|
190
|
+
|
|
191
|
+
**Brief (fallback):** The software that passes QA is not what survives production. Integration points
|
|
192
|
+
are the number-one killer — a slow response is worse than none. Non-negotiables: connect + read
|
|
193
|
+
timeouts on every outbound call; a Circuit Breaker on failing dependencies (trips open, fails fast,
|
|
194
|
+
half-open recovery); Bulkheads to isolate resource pools; Retry with exponential backoff + jitter;
|
|
195
|
+
Steady State cleanup of accumulating cruft. Decouple deploy from release with feature flags and
|
|
196
|
+
expand-contract migrations. Add deep health checks, RED metrics, symptom-based alerts.
|
|
197
|
+
|
|
198
|
+
**Invoke:** Use the `release-it` skill with the outbound dependencies from intake. Ask for an audit of calls with no timeout, circuit-breaker + bulkhead placement, and a deep health check + RED metrics + alert design.
|
|
199
|
+
|
|
200
|
+
**Decide with the user:** Breaker thresholds, which dependencies get dedicated pools, and the alert symptoms and thresholds (error rate, latency).
|
|
201
|
+
|
|
202
|
+
**Artifact:** Create docs/RELIABILITY.md with `## Integration-Point Audit` (dependency | timeout | circuit breaker | bulkhead | retry policy | status), `## Health Checks & Metrics`, and `## Deploy vs Release`. Update the tracker.
|
|
203
|
+
|
|
204
|
+
**Done when:** every outbound call has a timeout, critical dependencies have breakers and bulkheads, a deep health check + RED metrics + symptom alerts exist, steady-state cleanup is scheduled for accumulating cruft, a release can be rolled back without a redeploy, and the audit table has no open rows for critical paths.
|
|
205
|
+
|
|
206
|
+
### Phase 8 — Size for real load (system-design)
|
|
207
|
+
|
|
208
|
+
**Purpose:** Scale deliberately from requirements and numbers, not reactively — add machinery only when estimates justify it.
|
|
209
|
+
|
|
210
|
+
**Brief (fallback):** Start with requirements, not solutions. Back-of-envelope: QPS =
|
|
211
|
+
daily-active-users × actions/day ÷ 86,400, peak 2-5× average; storage = records/day × size ×
|
|
212
|
+
retention. Scale in order: vertical first, then cache (cache-aside with a TTL and explicit
|
|
213
|
+
invalidation) for read-heavy paths, then read replicas, and shard only as a last resort. Use a
|
|
214
|
+
message queue to decouple slow work from the request path. Reach for known designs (rate limiter →
|
|
215
|
+
token bucket returning `429 Retry-After`).
|
|
216
|
+
|
|
217
|
+
**Invoke:** Use the `system-design` skill with the load reality from intake. Ask for average and peak QPS, yearly storage, which component bottlenecks first, and a priority-ordered list of cache / queue / replica moves without over-engineering.
|
|
218
|
+
|
|
219
|
+
**Decide with the user:** Which scaling moves to make now versus defer, tied to the actual numbers (don't build for 50k users while at 50), and name the first slow workload to move behind a message queue, if any.
|
|
220
|
+
|
|
221
|
+
**Artifact:** Extend docs/ARCHITECTURE.md `## System Context` with the load reality and back-of-envelope numbers; extend docs/RELIABILITY.md `## Query & Resource Findings` with unbounded queries and bottlenecks. Update the tracker.
|
|
222
|
+
|
|
223
|
+
**Done when:** the QPS and storage numbers are recorded, the first bottleneck is named, and each scaling move is either applied or deferred with the triggering number written down.
|
|
224
|
+
|
|
225
|
+
### Phase 9 — Get the data layer right (ddia-systems)
|
|
226
|
+
|
|
227
|
+
**Purpose:** Protect the data that outlives the code — correctness under concurrency, and datastore choices made by requirement, not habit.
|
|
228
|
+
|
|
229
|
+
**Brief (fallback):** Data outlives code. Most databases default to read-committed or snapshot, not
|
|
230
|
+
serializable — naive read-then-write triggers write skew (two requests both selling the last item).
|
|
231
|
+
Fix explicitly with `SELECT ... FOR UPDATE` or a serializable transaction; know your actual default.
|
|
232
|
+
Replication lag means read-your-writes and monotonic-reads must be deliberate once replicas exist.
|
|
233
|
+
Match data model to access pattern; polyglot persistence is often correct; separate system-of-record
|
|
234
|
+
from derived data (CDC / event sourcing) rather than dual writes.
|
|
235
|
+
|
|
236
|
+
**Invoke:** Use the `ddia-systems` skill with the database from intake and the replica plan from Phase 8. Ask it to find write-skew-prone read-then-write paths, state the actual default isolation level and its anomalies, and fix the risky paths.
|
|
237
|
+
|
|
238
|
+
**Decide with the user:** Which paths need locking versus a serializable transaction, and whether a new workload (search, feed) justifies a second datastore kept in sync by CDC.
|
|
239
|
+
|
|
240
|
+
**Artifact:** Extend docs/ARCHITECTURE.md `## Data & Storage Decisions` with the isolation level, locked paths, and any polyglot / derived-data choices; log the reasoning in `## Decision Log`. Update the tracker.
|
|
241
|
+
|
|
242
|
+
**Done when:** the default isolation level is documented, every write-skew-prone path is locked or made serializable, and any new datastore has a defined sync mechanism.
|
|
243
|
+
|
|
244
|
+
## Optional Phases
|
|
245
|
+
|
|
246
|
+
| Skill | Add when | Artifact |
|
|
247
|
+
|---|---|---|
|
|
248
|
+
| domain-driven-design | Business logic tangles because the code speaks no domain language | Extends docs/ARCHITECTURE.md (`## Bounded Contexts & Context Map`, `## Domain Glossary (Ubiquitous Language)`) |
|
|
249
|
+
|
|
250
|
+
Optional phases follow the same operating rules — load and use each listed skill exactly as a core phase would; insert where the Add-when condition first becomes true — here, right after Phase 5 once the boundary exists.
|
|
251
|
+
|
|
252
|
+
## Common Mistakes
|
|
253
|
+
|
|
254
|
+
| Mistake | Fix |
|
|
255
|
+
|---|---|
|
|
256
|
+
| Cleaning up before writing a single test | Pin behavior with characterization tests in Phase 1 (working-with-legacy-code) first; the safety net gates every later phase. |
|
|
257
|
+
| Letting the agent "modularize" into a swarm of tiny classes | Apply software-design-philosophy's deep-module rule — merge shallow classes that travel together; reduce interfaces, don't multiply them. |
|
|
258
|
+
| Calling external APIs with no timeout | In Phase 7 (release-it) add connect + read timeouts on every outbound call, plus a circuit breaker on critical dependencies. |
|
|
259
|
+
| Scaling before sizing anything | Do back-of-envelope estimation first (system-design); the numbers usually say a cache and a read replica are years of runway. |
|
|
260
|
+
| Mistaking microservices for architecture | Apply the Dependency Rule inside the service first (clean-architecture); services sharing one data model are a distributed monolith. |
|
|
261
|
+
| Assuming the database is serializable | Check the actual default isolation level and lock read-then-write paths (ddia-systems) — write skew passes every single-user test. |
|
|
262
|
+
|
|
263
|
+
## Completing the Journey
|
|
264
|
+
|
|
265
|
+
Ship in order, not all at once: Phases 1-3 (net, readability, refactoring) belong before real users arrive; the Phase 5 boundary pays off most before the codebase doubles again; harden Phase 7 before launch (timeouts and a breaker are not optional even at low traffic); let Phases 8-9 track your actual growth numbers.
|
|
266
|
+
|
|
267
|
+
Exit checklist — every box tied to an artifact:
|
|
268
|
+
|
|
269
|
+
- [ ] Business rules have tests that run with no database or framework (TESTING.md Safety Net Map complete for changed modules).
|
|
270
|
+
- [ ] Every outbound call has a timeout, critical dependencies have circuit breakers, and a deep health check + RED metrics are wired to symptom-based alerts (RELIABILITY.md Integration-Point Audit clear, Health Checks & Metrics filled).
|
|
271
|
+
- [ ] Dependency Rule holds — business logic imports no framework or ORM (ARCHITECTURE.md Layer Map, violations closed).
|
|
272
|
+
- [ ] Database isolation level known and read-then-write paths locked (ARCHITECTURE.md Data & Storage Decisions).
|
|
273
|
+
- [ ] No untracked hacks remain; every deferred item is a Debt Ledger row with priority (TECH-DEBT.md).
|
|
274
|
+
|
|
275
|
+
Close the tracker: every phase `done` or `skipped: reason`, with remaining Next Actions carried into the TECH-DEBT.md Debt Ledger so nothing is lost. Then route forward: when the codebase is old and large rather than young and messy, continue with the `remove-technical-debt` skill; when the next system deserves deliberate structure from day one, continue with the `design-code-architecture` skill.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Artifact Templates — improve-code-quality
|
|
2
|
+
|
|
3
|
+
Skeletons this metaskill creates in the user's `docs/` folder. Extend-only artifacts (ARCHITECTURE.md) are governed by the section headings named in each phase, not duplicated here. Copy a skeleton verbatim the first time you create its file; on later phases, extend the existing file — add or update your own sections, preserve everyone else's.
|
|
4
|
+
|
|
5
|
+
## docs/IMPROVE-CODE-QUALITY-PLAN.md (tracker)
|
|
6
|
+
|
|
7
|
+
Created on first run; never shared with other journeys. The Phase Status table is pre-filled with this journey's real phases.
|
|
8
|
+
|
|
9
|
+
```markdown
|
|
10
|
+
# Improve Code Quality Plan
|
|
11
|
+
|
|
12
|
+
## Context
|
|
13
|
+
Intake answers, date started, project specifics (stack, starting module, production status, load).
|
|
14
|
+
|
|
15
|
+
## Phase Status
|
|
16
|
+
| Phase | Skill | Status | Artifact | Date |
|
|
17
|
+
|---|---|---|---|---|
|
|
18
|
+
| 1 — Build the safety net | working-with-legacy-code | pending | TESTING.md + TECH-DEBT.md (GATE) | |
|
|
19
|
+
| 2 — Make the code readable | clean-code | pending | TECH-DEBT.md | |
|
|
20
|
+
| 3 — Apply named refactorings | refactoring-patterns | pending | TECH-DEBT.md | |
|
|
21
|
+
| 4 — Reduce complexity | software-design-philosophy | pending | TECH-DEBT.md | |
|
|
22
|
+
| 5 — Draw the architecture boundary | clean-architecture | pending | ARCHITECTURE.md | |
|
|
23
|
+
| 6 — Lock in the habits | pragmatic-programmer | pending | TECH-DEBT.md | |
|
|
24
|
+
| 7 — Make it survive production | release-it | pending | RELIABILITY.md | |
|
|
25
|
+
| 8 — Size for real load | system-design | pending | ARCHITECTURE.md + RELIABILITY.md | |
|
|
26
|
+
| 9 — Get the data layer right | ddia-systems | pending | ARCHITECTURE.md | |
|
|
27
|
+
| Optional — Domain language | domain-driven-design | pending | ARCHITECTURE.md | |
|
|
28
|
+
Statuses: pending · in-progress · awaiting-evidence · done · deferred: <reason> · skipped: <reason>
|
|
29
|
+
|
|
30
|
+
## Key Decisions
|
|
31
|
+
| Date | Phase | Decision | Rationale |
|
|
32
|
+
|---|---|---|---|
|
|
33
|
+
|
|
34
|
+
## Next Actions
|
|
35
|
+
- [ ] action (owner, due)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## docs/TESTING.md
|
|
39
|
+
|
|
40
|
+
Created in Phase 1. The safety net — what behavior is pinned, where the gaps are.
|
|
41
|
+
|
|
42
|
+
```markdown
|
|
43
|
+
# Testing
|
|
44
|
+
|
|
45
|
+
## Test Strategy
|
|
46
|
+
Pyramid, tooling, what "green" gates.
|
|
47
|
+
|
|
48
|
+
## Safety Net Map
|
|
49
|
+
| Module | Pinned behaviors | Test files | Gaps |
|
|
50
|
+
|---|---|---|---|
|
|
51
|
+
|
|
52
|
+
## Characterization Backlog
|
|
53
|
+
- [ ] module (risk, priority)
|
|
54
|
+
|
|
55
|
+
## CI Gates
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## docs/TECH-DEBT.md
|
|
59
|
+
|
|
60
|
+
Created in Phase 1; extended in Phases 2, 3, 4, and 6. The debt ledger — single queue for all code-quality work.
|
|
61
|
+
|
|
62
|
+
```markdown
|
|
63
|
+
# Technical Debt
|
|
64
|
+
|
|
65
|
+
## Debt Ledger
|
|
66
|
+
| Item | Location | Type | Risk | Effort | Priority | Status |
|
|
67
|
+
|---|---|---|---|---|---|---|
|
|
68
|
+
|
|
69
|
+
## Smell Inventory
|
|
70
|
+
| Smell | Location | Refactoring | Status |
|
|
71
|
+
|---|---|---|---|
|
|
72
|
+
|
|
73
|
+
## Sprout / Wrap Register
|
|
74
|
+
Code added beside legacy (to fold back in later).
|
|
75
|
+
|
|
76
|
+
## Debt Budget & Broken-Windows Policy
|
|
77
|
+
Time per iteration; what gets fixed now vs boarded up with a ticket.
|
|
78
|
+
|
|
79
|
+
## Adopted Conventions
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## docs/RELIABILITY.md
|
|
83
|
+
|
|
84
|
+
Created in Phase 7; extended in Phase 8. Production hardening status.
|
|
85
|
+
|
|
86
|
+
```markdown
|
|
87
|
+
# Reliability
|
|
88
|
+
|
|
89
|
+
## Integration-Point Audit
|
|
90
|
+
| Dependency | Timeout | Circuit breaker | Bulkhead | Retry policy | Status |
|
|
91
|
+
|---|---|---|---|---|---|
|
|
92
|
+
|
|
93
|
+
## Query & Resource Findings
|
|
94
|
+
Unbounded result sets, missing LIMITs/pagination, blocked threads.
|
|
95
|
+
|
|
96
|
+
## Health Checks & Metrics
|
|
97
|
+
Deep health checks · RED metrics · symptom-based alerts.
|
|
98
|
+
|
|
99
|
+
## Deploy vs Release
|
|
100
|
+
Feature flags, expand-contract migrations, rollback plan.
|
|
101
|
+
```
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: incremental-implementation
|
|
3
|
+
description: Delivers changes incrementally in thin, verifiable slices. Use when implementing any feature or change that touches more than one file, or when picking up the next task from a plan. Use when rolling a change out behind a feature flag, when you're about to write a large amount of code at once, or when a task feels too big to land in one step.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Incremental Implementation
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Build in thin vertical slices — implement one piece, test it, verify it, then expand. Avoid implementing an entire feature in one pass. Each increment should leave the system in a working, testable state. This is the execution discipline that makes large features manageable.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
- Implementing any multi-file change
|
|
15
|
+
- Building a new feature from a task breakdown
|
|
16
|
+
- Refactoring existing code
|
|
17
|
+
- Any time you're tempted to write more than ~100 lines before testing
|
|
18
|
+
|
|
19
|
+
**When NOT to use:** Single-file, single-function changes where the scope is already minimal.
|
|
20
|
+
|
|
21
|
+
## The Increment Cycle
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
┌──────────────────────────────────────┐
|
|
25
|
+
│ │
|
|
26
|
+
│ Implement ──→ Test ──→ Verify ──┐ │
|
|
27
|
+
│ ▲ │ │
|
|
28
|
+
│ └───── Commit ◄─────────────┘ │
|
|
29
|
+
│ │ │
|
|
30
|
+
│ ▼ │
|
|
31
|
+
│ Next slice │
|
|
32
|
+
│ │
|
|
33
|
+
└──────────────────────────────────────┘
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
For each slice:
|
|
37
|
+
|
|
38
|
+
1. **Implement** the smallest complete piece of functionality
|
|
39
|
+
2. **Test** — run the test suite (or write a test if none exists)
|
|
40
|
+
3. **Verify** — confirm the slice works as expected (tests pass, build succeeds, manual check)
|
|
41
|
+
4. **Commit** -- save your progress with a descriptive message (see `git-workflow-and-versioning` for atomic commit guidance)
|
|
42
|
+
5. **Move to the next slice** — carry forward, don't restart
|
|
43
|
+
|
|
44
|
+
## Slicing Strategies
|
|
45
|
+
|
|
46
|
+
### Vertical Slices (Preferred)
|
|
47
|
+
|
|
48
|
+
Build one complete path through the stack:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
Slice 1: Create a task (DB + API + basic UI)
|
|
52
|
+
→ Tests pass, user can create a task via the UI
|
|
53
|
+
|
|
54
|
+
Slice 2: List tasks (query + API + UI)
|
|
55
|
+
→ Tests pass, user can see their tasks
|
|
56
|
+
|
|
57
|
+
Slice 3: Edit a task (update + API + UI)
|
|
58
|
+
→ Tests pass, user can modify tasks
|
|
59
|
+
|
|
60
|
+
Slice 4: Delete a task (delete + API + UI + confirmation)
|
|
61
|
+
→ Tests pass, full CRUD complete
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Each slice delivers working end-to-end functionality.
|
|
65
|
+
|
|
66
|
+
### Contract-First Slicing
|
|
67
|
+
|
|
68
|
+
When backend and frontend need to develop in parallel:
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
Slice 0: Define the API contract (types, interfaces, OpenAPI spec)
|
|
72
|
+
Slice 1a: Implement backend against the contract + API tests
|
|
73
|
+
Slice 1b: Implement frontend against mock data matching the contract
|
|
74
|
+
Slice 2: Integrate and test end-to-end
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Risk-First Slicing
|
|
78
|
+
|
|
79
|
+
Tackle the riskiest or most uncertain piece first:
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
Slice 1: Prove the WebSocket connection works (highest risk)
|
|
83
|
+
Slice 2: Build real-time task updates on the proven connection
|
|
84
|
+
Slice 3: Add offline support and reconnection
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
If Slice 1 fails, you discover it before investing in Slices 2 and 3.
|
|
88
|
+
|
|
89
|
+
## Implementation Rules
|
|
90
|
+
|
|
91
|
+
### Rule 0: Simplicity First
|
|
92
|
+
|
|
93
|
+
Before writing any code, ask: "What is the simplest thing that could work?"
|
|
94
|
+
|
|
95
|
+
After writing code, review it against these checks:
|
|
96
|
+
- Can this be done in fewer lines?
|
|
97
|
+
- Are these abstractions earning their complexity?
|
|
98
|
+
- Would a staff engineer look at this and say "why didn't you just..."?
|
|
99
|
+
- Am I building for hypothetical future requirements, or the current task?
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
SIMPLICITY CHECK:
|
|
103
|
+
✗ Generic EventBus with middleware pipeline for one notification
|
|
104
|
+
✓ Simple function call
|
|
105
|
+
|
|
106
|
+
✗ Abstract factory pattern for two similar components
|
|
107
|
+
✓ Two straightforward components with shared utilities
|
|
108
|
+
|
|
109
|
+
✗ Config-driven form builder for three forms
|
|
110
|
+
✓ Three form components
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Three similar lines of code is better than a premature abstraction. Implement the naive, obviously-correct version first. Optimize only after correctness is proven with tests.
|
|
114
|
+
|
|
115
|
+
### Rule 0.5: Scope Discipline
|
|
116
|
+
|
|
117
|
+
Touch only what the task requires.
|
|
118
|
+
|
|
119
|
+
Do NOT:
|
|
120
|
+
- "Clean up" code adjacent to your change
|
|
121
|
+
- Refactor imports in files you're not modifying
|
|
122
|
+
- Remove comments you don't fully understand
|
|
123
|
+
- Add features not in the spec because they "seem useful"
|
|
124
|
+
- Modernize syntax in files you're only reading
|
|
125
|
+
|
|
126
|
+
If you notice something worth improving outside your task scope, note it — don't fix it:
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
NOTICED BUT NOT TOUCHING:
|
|
130
|
+
- src/utils/format.ts has an unused import (unrelated to this task)
|
|
131
|
+
- The auth middleware could use better error messages (separate task)
|
|
132
|
+
→ Want me to create tasks for these?
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Rule 1: One Thing at a Time
|
|
136
|
+
|
|
137
|
+
Each increment changes one logical thing. Don't mix concerns:
|
|
138
|
+
|
|
139
|
+
**Bad:** One commit that adds a new component, refactors an existing one, and updates the build config.
|
|
140
|
+
|
|
141
|
+
**Good:** Three separate commits — one for each change.
|
|
142
|
+
|
|
143
|
+
### Rule 2: Keep It Compilable
|
|
144
|
+
|
|
145
|
+
After each increment, the project must build and existing tests must pass. Don't leave the codebase in a broken state between slices.
|
|
146
|
+
|
|
147
|
+
### Rule 3: Feature Flags for Incomplete Features
|
|
148
|
+
|
|
149
|
+
If a feature isn't ready for users but you need to merge increments:
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
// Feature flag for work-in-progress
|
|
153
|
+
const ENABLE_TASK_SHARING = process.env.FEATURE_TASK_SHARING === 'true';
|
|
154
|
+
|
|
155
|
+
if (ENABLE_TASK_SHARING) {
|
|
156
|
+
// New sharing UI
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
This lets you merge small increments to the main branch without exposing incomplete work.
|
|
161
|
+
|
|
162
|
+
### Rule 4: Safe Defaults
|
|
163
|
+
|
|
164
|
+
New code should default to safe, conservative behavior:
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
// Safe: disabled by default, opt-in
|
|
168
|
+
export function createTask(data: TaskInput, options?: { notify?: boolean }) {
|
|
169
|
+
const shouldNotify = options?.notify ?? false;
|
|
170
|
+
// ...
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Rule 5: Rollback-Friendly
|
|
175
|
+
|
|
176
|
+
Each increment should be independently revertable:
|
|
177
|
+
|
|
178
|
+
- Additive changes (new files, new functions) are easy to revert
|
|
179
|
+
- Modifications to existing code should be minimal and focused
|
|
180
|
+
- Database migrations should have corresponding rollback migrations
|
|
181
|
+
- Avoid deleting something in one commit and replacing it in the same commit — separate them
|
|
182
|
+
|
|
183
|
+
## Working with Agents
|
|
184
|
+
|
|
185
|
+
When directing an agent to implement incrementally:
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
"Let's implement Task 3 from the plan.
|
|
189
|
+
|
|
190
|
+
Start with just the database schema change and the API endpoint.
|
|
191
|
+
Don't touch the UI yet — we'll do that in the next increment.
|
|
192
|
+
|
|
193
|
+
After implementing, run the repository's test and build commands to
|
|
194
|
+
verify nothing is broken."
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Be explicit about what's in scope and what's NOT in scope for each increment.
|
|
198
|
+
|
|
199
|
+
## Increment Checklist
|
|
200
|
+
|
|
201
|
+
After each increment, verify with the repository's own commands (see the test-driven-development skill's Discover the Stack First section):
|
|
202
|
+
|
|
203
|
+
- [ ] The change does one thing and does it completely
|
|
204
|
+
- [ ] All existing tests still pass (the repository's test command: `npm test`, `./gradlew test`, `pytest`, ...)
|
|
205
|
+
- [ ] The build succeeds (the repository's build command)
|
|
206
|
+
- [ ] Type checking passes, where the stack has one (`npx tsc --noEmit`, `mypy`, ...)
|
|
207
|
+
- [ ] Linting passes (the repository's lint command)
|
|
208
|
+
- [ ] The new functionality works as expected
|
|
209
|
+
- [ ] The change is committed with a descriptive message
|
|
210
|
+
|
|
211
|
+
**Note:** Run each verification command after a change that could affect it. After a successful run, don't repeat the same command unless the code has changed since — re-running on unchanged code adds no information.
|
|
212
|
+
|
|
213
|
+
## Common Rationalizations
|
|
214
|
+
|
|
215
|
+
| Rationalization | Reality |
|
|
216
|
+
|---|---|
|
|
217
|
+
| "I'll test it all at the end" | Bugs compound. A bug in Slice 1 makes Slices 2-5 wrong. Test each slice. |
|
|
218
|
+
| "It's faster to do it all at once" | It *feels* faster until something breaks and you can't find which of 500 changed lines caused it. |
|
|
219
|
+
| "These changes are too small to commit separately" | Small commits are free. Large commits hide bugs and make rollbacks painful. |
|
|
220
|
+
| "I'll add the feature flag later" | If the feature isn't complete, it shouldn't be user-visible. Add the flag now. |
|
|
221
|
+
| "This refactor is small enough to include" | Refactors mixed with features make both harder to review and debug. Separate them. |
|
|
222
|
+
| "Let me run the build command again just to be sure" | After a successful run, repeating the same command adds nothing unless the code has changed since. Run it again after subsequent edits, not as reassurance. |
|
|
223
|
+
|
|
224
|
+
## Red Flags
|
|
225
|
+
|
|
226
|
+
- More than 100 lines of code written without running tests
|
|
227
|
+
- Multiple unrelated changes in a single increment
|
|
228
|
+
- "Let me just quickly add this too" scope expansion
|
|
229
|
+
- Skipping the test/verify step to move faster
|
|
230
|
+
- Build or tests broken between increments
|
|
231
|
+
- Large uncommitted changes accumulating
|
|
232
|
+
- Building abstractions before the third use case demands it
|
|
233
|
+
- Touching files outside the task scope "while I'm here"
|
|
234
|
+
- Creating new utility files for one-time operations
|
|
235
|
+
- Running the same build/test command twice in a row without any intervening code change
|
|
236
|
+
|
|
237
|
+
## Verification
|
|
238
|
+
|
|
239
|
+
After completing all increments for a task:
|
|
240
|
+
|
|
241
|
+
- [ ] Each increment was individually tested and committed
|
|
242
|
+
- [ ] The full test suite passes
|
|
243
|
+
- [ ] The build is clean
|
|
244
|
+
- [ ] The feature works end-to-end as specified
|
|
245
|
+
- [ ] No uncommitted changes remain
|
|
246
|
+
|
|
247
|
+
## See Also
|
|
248
|
+
|
|
249
|
+
Per-increment verification is the local check. Before declaring a task done, apply the project-wide Definition of Done as the final gate, the standing bar every increment clears regardless of the task. See `${CLAUDE_SKILL_DIR}/../_references/definition-of-done.md`.
|