@givolt/i3-composer-agent 0.0.0-stage → 1.0.0
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.
- package/.agents/plugins/marketplace.json +23 -0
- package/.claude/commands/build.md +44 -0
- package/.claude/commands/code-simplify.md +22 -0
- package/.claude/commands/constraints.md +32 -0
- package/.claude/commands/plan.md +18 -0
- package/.claude/commands/review.md +16 -0
- package/.claude/commands/ship.md +72 -0
- package/.claude/commands/spec.md +17 -0
- package/.claude/commands/test.md +19 -0
- package/.claude/commands/webperf.md +32 -0
- package/.claude-plugin/marketplace.json +27 -0
- package/.claude-plugin/plugin.json +19 -0
- package/.codex-plugin/plugin.json +28 -0
- package/.gemini/commands/build.toml +43 -0
- package/.gemini/commands/code-simplify.toml +22 -0
- package/.gemini/commands/constraints.toml +32 -0
- package/.gemini/commands/planning.toml +18 -0
- package/.gemini/commands/review.toml +16 -0
- package/.gemini/commands/ship.toml +72 -0
- package/.gemini/commands/spec.toml +17 -0
- package/.gemini/commands/test.toml +19 -0
- package/.gemini/commands/webperf.toml +32 -0
- package/CHANGELOG.md +23 -0
- package/LICENSE +21 -0
- package/NOTICE.md +9 -0
- package/README.md +117 -2
- package/agents/code-reviewer.md +102 -0
- package/agents/security-auditor.md +112 -0
- package/agents/test-engineer.md +95 -0
- package/agents/web-performance-auditor.md +184 -0
- package/bin/i3-composer-agent.cjs +122 -0
- package/commands/build.toml +43 -0
- package/commands/code-simplify.toml +22 -0
- package/commands/constraints.toml +32 -0
- package/commands/planning.toml +18 -0
- package/commands/review.toml +16 -0
- package/commands/ship.toml +72 -0
- package/commands/spec.toml +17 -0
- package/commands/test.toml +19 -0
- package/commands/webperf.toml +32 -0
- package/docs/adoption-guide.md +129 -0
- package/docs/advanced-per-agent-configuration.md +70 -0
- package/docs/agents.md +123 -0
- package/docs/antigravity-setup.md +128 -0
- package/docs/codebuddy-setup.md +41 -0
- package/docs/codex-setup.md +34 -0
- package/docs/commandcode-setup.md +69 -0
- package/docs/comparison.md +131 -0
- package/docs/copilot-cli-setup.md +64 -0
- package/docs/copilot-setup.md +162 -0
- package/docs/cursor-setup.md +225 -0
- package/docs/developer-onboarding.md +116 -0
- package/docs/gemini-cli-setup.md +133 -0
- package/docs/getting-started.md +208 -0
- package/docs/opencode-setup.md +259 -0
- package/docs/other-hosts.md +7 -0
- package/docs/skill-anatomy.md +203 -0
- package/docs/windsurf-setup.md +48 -0
- package/evals/README.md +101 -0
- package/evals/cases/api-and-interface-design.json +45 -0
- package/evals/cases/browser-testing-with-devtools.json +44 -0
- package/evals/cases/ci-cd-and-automation.json +45 -0
- package/evals/cases/code-review-and-quality.json +49 -0
- package/evals/cases/code-simplification.json +45 -0
- package/evals/cases/constraint-driven-development.json +79 -0
- package/evals/cases/context-engineering.json +44 -0
- package/evals/cases/debugging-and-error-recovery.json +58 -0
- package/evals/cases/deprecation-and-migration.json +52 -0
- package/evals/cases/documentation-and-adrs.json +44 -0
- package/evals/cases/doubt-driven-development.json +43 -0
- package/evals/cases/frontend-ui-engineering.json +52 -0
- package/evals/cases/git-workflow-and-versioning.json +47 -0
- package/evals/cases/idea-refine.json +43 -0
- package/evals/cases/incremental-implementation.json +57 -0
- package/evals/cases/interview-me.json +42 -0
- package/evals/cases/observability-and-instrumentation.json +44 -0
- package/evals/cases/performance-optimization.json +53 -0
- package/evals/cases/planning-and-task-breakdown.json +45 -0
- package/evals/cases/security-and-hardening.json +53 -0
- package/evals/cases/shipping-and-launch.json +56 -0
- package/evals/cases/source-driven-development.json +44 -0
- package/evals/cases/spec-driven-development.json +72 -0
- package/evals/cases/test-driven-development.json +73 -0
- package/evals/cases/using-agent-skills.json +44 -0
- package/evals/fixtures/api-and-interface-design/service-brief.md +19 -0
- package/evals/fixtures/browser-testing-with-devtools/README.md +5 -0
- package/evals/fixtures/browser-testing-with-devtools/index.html +24 -0
- package/evals/fixtures/browser-testing-with-devtools/server.js +15 -0
- package/evals/fixtures/ci-cd-and-automation/package.json +8 -0
- package/evals/fixtures/ci-cd-and-automation/src/slug.js +3 -0
- package/evals/fixtures/ci-cd-and-automation/test/slug.test.js +9 -0
- package/evals/fixtures/code-review-and-quality/user-search.diff +16 -0
- package/evals/fixtures/code-simplification/config-parser.js +46 -0
- package/evals/fixtures/code-simplification/config-parser.test.js +15 -0
- package/evals/fixtures/context-engineering/context-audit.md +15 -0
- package/evals/fixtures/debugging-and-error-recovery/pagination.js +8 -0
- package/evals/fixtures/debugging-and-error-recovery/pagination.test.js +9 -0
- package/evals/fixtures/debugging-and-error-recovery/time-pressure.md +6 -0
- package/evals/fixtures/deprecation-and-migration/api-inventory.md +9 -0
- package/evals/fixtures/documentation-and-adrs/decision-context.md +16 -0
- package/evals/fixtures/doubt-driven-development/migration-plan.md +19 -0
- package/evals/fixtures/frontend-ui-engineering/Button.tsx +7 -0
- package/evals/fixtures/frontend-ui-engineering/design-system.md +11 -0
- package/evals/fixtures/git-workflow-and-versioning/.eval/working-tree.patch +21 -0
- package/evals/fixtures/git-workflow-and-versioning/app.js +7 -0
- package/evals/fixtures/git-workflow-and-versioning/app.test.js +9 -0
- package/evals/fixtures/incremental-implementation/reports.js +7 -0
- package/evals/fixtures/incremental-implementation/reports.test.js +12 -0
- package/evals/fixtures/incremental-implementation/tasks/plan.md +8 -0
- package/evals/fixtures/incremental-implementation-pressure/draft-export.js +17 -0
- package/evals/fixtures/incremental-implementation-pressure/scenario.md +9 -0
- package/evals/fixtures/observability-and-instrumentation/operations.md +11 -0
- package/evals/fixtures/observability-and-instrumentation/payment-retry.js +14 -0
- package/evals/fixtures/performance-optimization/benchmark.js +15 -0
- package/evals/fixtures/performance-optimization/products.js +14 -0
- package/evals/fixtures/planning-and-task-breakdown/notifications-spec.md +18 -0
- package/evals/fixtures/security-and-hardening/webhook.js +11 -0
- package/evals/fixtures/security-and-hardening/webhook.test.js +13 -0
- package/evals/fixtures/shipping-and-launch/authority-pressure.md +6 -0
- package/evals/fixtures/shipping-and-launch/launch-status.md +11 -0
- package/evals/fixtures/source-driven-development/framework-task.md +10 -0
- package/evals/fixtures/spec-driven-development/billing-brief.md +16 -0
- package/evals/fixtures/spec-driven-development-decomposition/portal-brief.md +22 -0
- package/evals/fixtures/test-driven-development/BUG.md +10 -0
- package/evals/fixtures/test-driven-development/README.md +28 -0
- package/evals/fixtures/test-driven-development/package.json +9 -0
- package/evals/fixtures/test-driven-development/src/split.js +8 -0
- package/evals/fixtures/test-driven-development/test/split.test.js +13 -0
- package/evals/fixtures/test-driven-development-ecosystem/README.md +9 -0
- package/evals/fixtures/test-driven-development-ecosystem/ledger.py +15 -0
- package/evals/fixtures/test-driven-development-ecosystem/test_ledger.py +19 -0
- package/evals/fixtures/using-agent-skills/incident.md +6 -0
- package/evals/plugin/code-review-fires/graders/off-by-one.md +7 -0
- package/evals/plugin/code-review-fires/graders/severity-labels.md +4 -0
- package/evals/plugin/code-review-fires/graders/skill-fired.md +5 -0
- package/evals/plugin/code-review-fires/prompt.md +31 -0
- package/evals/plugin/code-review-stays-quiet/graders/not-fired.md +8 -0
- package/evals/plugin/code-review-stays-quiet/graders/tdd-fired.md +6 -0
- package/evals/plugin/code-review-stays-quiet/prompt.md +8 -0
- package/evals/plugin/code-review-stays-quiet-on-commit-message/graders/not-fired.md +8 -0
- package/evals/plugin/code-review-stays-quiet-on-commit-message/prompt.md +25 -0
- package/evals/skill-impact.md +6 -0
- package/hooks/SDD-CACHE.md +167 -0
- package/hooks/SIMPLIFY-IGNORE.md +91 -0
- package/hooks/sdd-cache-post.sh +135 -0
- package/hooks/sdd-cache-pre.sh +106 -0
- package/hooks/sdd-cache-test.sh +246 -0
- package/hooks/session-start-test.sh +47 -0
- package/hooks/session-start.sh +33 -0
- package/hooks/simplify-ignore-test.sh +476 -0
- package/hooks/simplify-ignore.sh +352 -0
- package/package.json +89 -4
- package/plugin.json +7 -0
- package/rebrand/MAINTENANCE.md +112 -0
- package/rebrand/NOTICE.md +9 -0
- package/rebrand/PR-WORKFLOW.md +34 -0
- package/rebrand/UNIFICATION-SPEC.md +33 -0
- package/rebrand/VALIDATION.md +28 -0
- package/rebrand/VERSIONING.md +32 -0
- package/rebrand/apply.cjs +194 -0
- package/rebrand/brand.json +13 -0
- package/rebrand/catalog.cjs +56 -0
- package/rebrand/fork-patches.json +12 -0
- package/rebrand/overlay/.github/workflows/test-plugin-install.yml +177 -0
- package/rebrand/overlay/CHANGELOG.md +23 -0
- package/rebrand/overlay/bin/i3-composer-agent.cjs +122 -0
- package/rebrand/overlay/scripts/validate-brand.cjs +44 -0
- package/rebrand/overlay/tests/bundle.test.cjs +85 -0
- package/rebrand/package.template.json +82 -0
- package/rebrand/rebrand.sh +4 -0
- package/rebrand/record-upstream.cjs +37 -0
- package/rebrand/templates/README.md +86 -0
- package/rebrand/templates/codebuddy-setup.md +41 -0
- package/rebrand/templates/codex-setup.md +34 -0
- package/rebrand/tests/pipeline.test.cjs +185 -0
- package/rebrand/upstream.json +171 -0
- package/references/accessibility-checklist.md +160 -0
- package/references/definition-of-done.md +67 -0
- package/references/observability-checklist.md +92 -0
- package/references/orchestration-patterns.md +370 -0
- package/references/performance-checklist.md +236 -0
- package/references/security-checklist.md +248 -0
- package/references/testing-patterns.md +235 -0
- package/scripts/floor-guard-reference-test.js +291 -0
- package/scripts/lib/skill-lint-test.js +650 -0
- package/scripts/lib/skill-lint.js +584 -0
- package/scripts/run-evals-test.js +623 -0
- package/scripts/run-evals.js +638 -0
- package/scripts/validate-artifact-paths-test.js +179 -0
- package/scripts/validate-artifact-paths.js +128 -0
- package/scripts/validate-brand.cjs +44 -0
- package/scripts/validate-commands-test.js +216 -0
- package/scripts/validate-commands.js +222 -0
- package/scripts/validate-reference-links-test.js +495 -0
- package/scripts/validate-reference-links.js +187 -0
- package/scripts/validate-skills.js +69 -0
- package/scripts/validate-versions-test.js +32 -0
- package/scripts/validate-versions.js +35 -0
- package/skills/api-and-interface-design/SKILL.md +367 -0
- package/skills/browser-testing-with-devtools/SKILL.md +317 -0
- package/skills/ci-cd-and-automation/SKILL.md +390 -0
- package/skills/code-review-and-quality/SKILL.md +398 -0
- package/skills/code-simplification/SKILL.md +331 -0
- package/skills/constraint-driven-development/SKILL.md +311 -0
- package/skills/constraint-driven-development/references/floor-guard.md +182 -0
- package/skills/context-engineering/SKILL.md +353 -0
- package/skills/debugging-and-error-recovery/SKILL.md +300 -0
- package/skills/deprecation-and-migration/SKILL.md +247 -0
- package/skills/documentation-and-adrs/SKILL.md +288 -0
- package/skills/doubt-driven-development/SKILL.md +243 -0
- package/skills/frontend-ui-engineering/SKILL.md +340 -0
- package/skills/git-workflow-and-versioning/SKILL.md +355 -0
- package/skills/idea-refine/SKILL.md +178 -0
- package/skills/idea-refine/examples.md +238 -0
- package/skills/idea-refine/frameworks.md +99 -0
- package/skills/idea-refine/refinement-criteria.md +113 -0
- package/skills/idea-refine/scripts/idea-refine.sh +15 -0
- package/skills/incremental-implementation/SKILL.md +249 -0
- package/skills/interview-me/SKILL.md +235 -0
- package/skills/observability-and-instrumentation/SKILL.md +238 -0
- package/skills/performance-optimization/SKILL.md +267 -0
- package/skills/performance-optimization/references/optimization-patterns.md +250 -0
- package/skills/planning-and-task-breakdown/SKILL.md +257 -0
- package/skills/security-and-hardening/SKILL.md +216 -0
- package/skills/security-and-hardening/references/hardening-patterns.md +324 -0
- package/skills/shipping-and-launch/SKILL.md +330 -0
- package/skills/source-driven-development/SKILL.md +216 -0
- package/skills/spec-driven-development/SKILL.md +259 -0
- package/skills/test-driven-development/SKILL.md +398 -0
- package/skills/using-agent-skills/SKILL.md +192 -0
- package/tests/bundle.test.cjs +85 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# Optimization Patterns
|
|
2
|
+
|
|
3
|
+
Worked fixes for the anti-patterns named in Step 3 of the `performance-optimization` skill. The skill states the rule and the signature to look for; this file shows one concrete implementation. Open the section you need after Step 2 has identified the bottleneck — it is not meant to be read top to bottom.
|
|
4
|
+
|
|
5
|
+
Checklists, measurement commands, TTFB diagnosis, and caching read/write strategies live in `../../../references/performance-checklist.md`.
|
|
6
|
+
|
|
7
|
+
## N+1 Queries (Backend)
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
// BAD: N+1 — one query per task for the owner
|
|
11
|
+
const tasks = await db.tasks.findMany();
|
|
12
|
+
for (const task of tasks) {
|
|
13
|
+
task.owner = await db.users.findUnique({ where: { id: task.ownerId } });
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// GOOD: Single query with join/include
|
|
17
|
+
const tasks = await db.tasks.findMany({
|
|
18
|
+
include: { owner: true },
|
|
19
|
+
});
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Unbounded Data Fetching
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
// BAD: Fetching all records
|
|
26
|
+
const allTasks = await db.tasks.findMany();
|
|
27
|
+
|
|
28
|
+
// GOOD: Paginated with limits
|
|
29
|
+
const tasks = await db.tasks.findMany({
|
|
30
|
+
take: 20,
|
|
31
|
+
skip: (page - 1) * 20,
|
|
32
|
+
orderBy: { createdAt: 'desc' },
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Queries That Ignore Their Index
|
|
37
|
+
|
|
38
|
+
"Add an index" is the guess. The query plan is the measurement:
|
|
39
|
+
|
|
40
|
+
```sql
|
|
41
|
+
EXPLAIN ANALYZE
|
|
42
|
+
SELECT id, title FROM tasks
|
|
43
|
+
WHERE owner_id = 42 ORDER BY created_at DESC LIMIT 20;
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Three things in the output decide the fix:
|
|
47
|
+
|
|
48
|
+
| What you see | What it means |
|
|
49
|
+
|---|---|
|
|
50
|
+
| `Seq Scan` on a large table where you expected an index | No usable index for this predicate |
|
|
51
|
+
| Estimated `rows=` off from actual by an order of magnitude | Stale statistics; the planner is choosing on bad information |
|
|
52
|
+
| A `Sort` node above the scan | The index covers the filter but not the `ORDER BY` |
|
|
53
|
+
|
|
54
|
+
Index for the **shape of the query**, not the column in isolation. In a composite index, equality columns come first, then the range or sort column:
|
|
55
|
+
|
|
56
|
+
```sql
|
|
57
|
+
CREATE INDEX idx_tasks_owner_created ON tasks (owner_id, created_at DESC);
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**When an index will not help:**
|
|
61
|
+
|
|
62
|
+
| Situation | Why |
|
|
63
|
+
|---|---|
|
|
64
|
+
| Low selectivity, querying the dominant value (a `status` column that is 95% `active`, filtered on `active`) | A sequential scan is genuinely cheaper; the planner will ignore the index. Filtering on the rare value is the opposite case, and a partial index serves it well |
|
|
65
|
+
| Leading wildcard (`LIKE '%term'`) | A B-tree cannot seek without a prefix; needs trigram or full-text |
|
|
66
|
+
| Function on the column (`WHERE lower(email) = ?`) | The plain column index is unusable; index the expression instead |
|
|
67
|
+
| Write-heavy table | Every index is a tax on every `INSERT`/`UPDATE`; measure the write cost, not just the read gain |
|
|
68
|
+
|
|
69
|
+
Re-run `EXPLAIN ANALYZE` after. An index that did not change the plan is a revert (Step 4), and it is not free: it still costs on every write.
|
|
70
|
+
|
|
71
|
+
## Connection Pool Exhaustion
|
|
72
|
+
|
|
73
|
+
The signature is distinctive: **every** endpoint slows at once, the slow time is spent waiting for a connection rather than executing, and the database reports mostly idle sessions.
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
// BAD: a pool per request or per module — under serverless this multiplies
|
|
77
|
+
// by instance count and exhausts the database's connection limit
|
|
78
|
+
// GOOD: one pool per process, sized against the database's ceiling
|
|
79
|
+
const pool = new Pool({
|
|
80
|
+
max: 10, // instances × max must stay under max_connections
|
|
81
|
+
idleTimeoutMillis: 30_000,
|
|
82
|
+
connectionTimeoutMillis: 5_000, // fail fast instead of queueing forever
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Bigger is not faster.** A pool larger than what the database can execute concurrently just relocates the queue from your app to the database, where it is harder to see. When instance count is unbounded (serverless, autoscaling), a proxy that multiplexes connections (pgbouncer, RDS Proxy) is the fix, not a higher `max`.
|
|
87
|
+
|
|
88
|
+
## Missing Image Optimization (Frontend)
|
|
89
|
+
|
|
90
|
+
```html
|
|
91
|
+
<!-- BAD: No dimensions, no format optimization -->
|
|
92
|
+
<img src="/hero.jpg" />
|
|
93
|
+
|
|
94
|
+
<!-- GOOD: Hero / LCP image — art direction + resolution switching, high priority -->
|
|
95
|
+
<!--
|
|
96
|
+
Two techniques combined:
|
|
97
|
+
- Art direction (media): different crop/composition per breakpoint
|
|
98
|
+
- Resolution switching (srcset + sizes): right file size per screen density
|
|
99
|
+
-->
|
|
100
|
+
<picture>
|
|
101
|
+
<!-- Mobile: portrait crop (8:10) -->
|
|
102
|
+
<source
|
|
103
|
+
media="(max-width: 767px)"
|
|
104
|
+
srcset="/hero-mobile-400.avif 400w, /hero-mobile-800.avif 800w"
|
|
105
|
+
sizes="100vw"
|
|
106
|
+
width="800"
|
|
107
|
+
height="1000"
|
|
108
|
+
type="image/avif"
|
|
109
|
+
/>
|
|
110
|
+
<source
|
|
111
|
+
media="(max-width: 767px)"
|
|
112
|
+
srcset="/hero-mobile-400.webp 400w, /hero-mobile-800.webp 800w"
|
|
113
|
+
sizes="100vw"
|
|
114
|
+
width="800"
|
|
115
|
+
height="1000"
|
|
116
|
+
type="image/webp"
|
|
117
|
+
/>
|
|
118
|
+
<!-- Desktop: landscape crop (2:1) -->
|
|
119
|
+
<source
|
|
120
|
+
srcset="/hero-800.avif 800w, /hero-1200.avif 1200w, /hero-1600.avif 1600w"
|
|
121
|
+
sizes="(max-width: 1200px) 100vw, 1200px"
|
|
122
|
+
width="1200"
|
|
123
|
+
height="600"
|
|
124
|
+
type="image/avif"
|
|
125
|
+
/>
|
|
126
|
+
<source
|
|
127
|
+
srcset="/hero-800.webp 800w, /hero-1200.webp 1200w, /hero-1600.webp 1600w"
|
|
128
|
+
sizes="(max-width: 1200px) 100vw, 1200px"
|
|
129
|
+
width="1200"
|
|
130
|
+
height="600"
|
|
131
|
+
type="image/webp"
|
|
132
|
+
/>
|
|
133
|
+
<img
|
|
134
|
+
src="/hero-desktop.jpg"
|
|
135
|
+
width="1200"
|
|
136
|
+
height="600"
|
|
137
|
+
fetchpriority="high"
|
|
138
|
+
alt="Hero image description"
|
|
139
|
+
/>
|
|
140
|
+
</picture>
|
|
141
|
+
|
|
142
|
+
<!-- GOOD: Below-the-fold image — lazy loaded + async decoding -->
|
|
143
|
+
<img
|
|
144
|
+
src="/content.webp"
|
|
145
|
+
width="800"
|
|
146
|
+
height="400"
|
|
147
|
+
loading="lazy"
|
|
148
|
+
decoding="async"
|
|
149
|
+
alt="Content image description"
|
|
150
|
+
/>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Unnecessary Re-renders (React)
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
// BAD: Creates new object on every render, causing children to re-render
|
|
157
|
+
function TaskList() {
|
|
158
|
+
return <TaskFilters options={{ sortBy: 'date', order: 'desc' }} />;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// GOOD: Stable reference
|
|
162
|
+
const DEFAULT_OPTIONS = { sortBy: 'date', order: 'desc' } as const;
|
|
163
|
+
function TaskList() {
|
|
164
|
+
return <TaskFilters options={DEFAULT_OPTIONS} />;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Use React.memo for expensive components
|
|
168
|
+
const TaskItem = React.memo(function TaskItem({ task }: Props) {
|
|
169
|
+
return <div>{/* expensive render */}</div>;
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// Use useMemo for expensive computations
|
|
173
|
+
function TaskStats({ tasks }: Props) {
|
|
174
|
+
const stats = useMemo(() => calculateStats(tasks), [tasks]);
|
|
175
|
+
return <div>{stats.completed} / {stats.total}</div>;
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Large Bundle Size
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
// Modern bundlers (Vite, webpack 5+) handle named imports with tree-shaking automatically,
|
|
183
|
+
// provided the dependency ships ESM and is marked `sideEffects: false` in package.json.
|
|
184
|
+
// Profile before changing import styles — the real gains come from splitting and lazy loading.
|
|
185
|
+
|
|
186
|
+
// GOOD: Dynamic import for heavy, rarely-used features
|
|
187
|
+
const ChartLibrary = lazy(() => import('./ChartLibrary'));
|
|
188
|
+
|
|
189
|
+
// GOOD: Route-level code splitting wrapped in Suspense
|
|
190
|
+
const SettingsPage = lazy(() => import('./pages/Settings'));
|
|
191
|
+
|
|
192
|
+
function App() {
|
|
193
|
+
return (
|
|
194
|
+
<Suspense fallback={<Spinner />}>
|
|
195
|
+
<SettingsPage />
|
|
196
|
+
</Suspense>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Missing Caching (Backend)
|
|
202
|
+
|
|
203
|
+
Cache what is expensive to produce and read far more often than it changes. Caching a query that was already fast adds a network hop, a staleness bug, and an eviction policy to maintain, in exchange for nothing.
|
|
204
|
+
|
|
205
|
+
**Pick the layer deliberately:**
|
|
206
|
+
|
|
207
|
+
| Layer | Visible to | Use when | Cost |
|
|
208
|
+
|---|---|---|---|
|
|
209
|
+
| In-process (`Map`, LRU) | One instance | Small, hot, per-instance staleness is acceptable | Each instance drifts independently; invalidation reaches only one |
|
|
210
|
+
| Shared (Redis, Memcached) | All instances | Instances must agree, or the value is expensive to recompute | A network hop, and another service to run and monitor |
|
|
211
|
+
| CDN / edge | Everyone, per URL | Responses are public and identical for a given key | Invalidation is the hard part; assume you cannot recall a bad response quickly |
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
// Cache frequently-read, rarely-changed data
|
|
215
|
+
const CACHE_TTL = 5 * 60 * 1000; // 5 minutes
|
|
216
|
+
let cachedConfig: AppConfig | null = null;
|
|
217
|
+
let cacheExpiry = 0;
|
|
218
|
+
|
|
219
|
+
async function getAppConfig(): Promise<AppConfig> {
|
|
220
|
+
if (cachedConfig && Date.now() < cacheExpiry) {
|
|
221
|
+
return cachedConfig;
|
|
222
|
+
}
|
|
223
|
+
cachedConfig = await db.config.findFirst();
|
|
224
|
+
cacheExpiry = Date.now() + CACHE_TTL;
|
|
225
|
+
return cachedConfig;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// HTTP caching headers for static assets
|
|
229
|
+
app.use('/static', express.static('public', {
|
|
230
|
+
maxAge: '1y', // Cache for 1 year
|
|
231
|
+
immutable: true, // Never revalidate (use content hashing in filenames)
|
|
232
|
+
}));
|
|
233
|
+
|
|
234
|
+
// Cache-Control for API responses
|
|
235
|
+
res.set('Cache-Control', 'public, max-age=300'); // 5 minutes
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**Key design decides correctness.** Every input that changes the response belongs in the key: tenant, locale, permissions, feature flags. A key that omits the viewer is how one user's data gets served to another, and that ships as a performance win.
|
|
239
|
+
|
|
240
|
+
**Choose one invalidation strategy, not three:**
|
|
241
|
+
|
|
242
|
+
| Strategy | Trade-off |
|
|
243
|
+
|---|---|
|
|
244
|
+
| TTL | Simplest. You accept staleness up to the TTL, so state the acceptable window explicitly |
|
|
245
|
+
| Event or tag based | Fresh on write, but writers now have to know the cache topology |
|
|
246
|
+
| Versioned keys (`user:42:profile:v7`) | Never invalidate, just stop reading old keys. Costs memory until eviction |
|
|
247
|
+
|
|
248
|
+
**Guard against the stampede.** A hot key expires, every concurrent request misses together, and the origin takes the full load at once, which is how a cache turns into an outage instead of preventing one. Serve stale while a single request recomputes (`stale-while-revalidate`), or coalesce concurrent misses behind one in-flight promise so N waiters cause one recompute.
|
|
249
|
+
|
|
250
|
+
**Do not cache:** anything whose staleness is a correctness bug (balances, permissions, inventory at checkout), or per-user data under a key that does not identify the user. See `../../../references/performance-checklist.md#caching-strategies` for request coalescing, write strategies, negative caching, and the cache checklist.
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: planning-and-task-breakdown
|
|
3
|
+
description: Breaks work into ordered tasks. Use when you have a spec or clear requirements and need to break work into implementable tasks. Use when a task feels too large to start, when you need to estimate scope, or when parallel work is possible.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Planning and Task Breakdown
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Decompose work into small, verifiable tasks with explicit acceptance criteria. Good task breakdown is the difference between an agent that completes work reliably and one that produces a tangled mess. Every task should be small enough to implement, test, and verify in a single focused session.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
- You have a spec and need to break it into implementable units
|
|
15
|
+
- A task feels too large or vague to start
|
|
16
|
+
- Work needs to be parallelized across multiple agents or sessions
|
|
17
|
+
- You need to communicate scope to a human
|
|
18
|
+
- The implementation order isn't obvious
|
|
19
|
+
|
|
20
|
+
**When NOT to use:** Single-file changes with obvious scope, or when the spec already contains well-defined tasks.
|
|
21
|
+
|
|
22
|
+
## The Planning Process
|
|
23
|
+
|
|
24
|
+
### Step 1: Enter Plan Mode
|
|
25
|
+
|
|
26
|
+
Before writing any code, operate in read-only mode:
|
|
27
|
+
|
|
28
|
+
- Read the spec and relevant codebase sections
|
|
29
|
+
- Identify existing patterns and conventions
|
|
30
|
+
- Map dependencies between components
|
|
31
|
+
- Note risks and unknowns
|
|
32
|
+
|
|
33
|
+
**Do NOT write code during planning.** The output is a plan document saved to `tasks/plan.md` and a task list recorded in the task list target (see Output Files; default `tasks/todo.md`), not implementation.
|
|
34
|
+
|
|
35
|
+
### Step 2: Identify the Dependency Graph
|
|
36
|
+
|
|
37
|
+
Map what depends on what:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
Database schema
|
|
41
|
+
│
|
|
42
|
+
├── API models/types
|
|
43
|
+
│ │
|
|
44
|
+
│ ├── API endpoints
|
|
45
|
+
│ │ │
|
|
46
|
+
│ │ └── Frontend API client
|
|
47
|
+
│ │ │
|
|
48
|
+
│ │ └── UI components
|
|
49
|
+
│ │
|
|
50
|
+
│ └── Validation logic
|
|
51
|
+
│
|
|
52
|
+
└── Seed data / migrations
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Implementation order follows the dependency graph bottom-up: build foundations first.
|
|
56
|
+
|
|
57
|
+
### Step 3: Slice Vertically
|
|
58
|
+
|
|
59
|
+
Instead of building all the database, then all the API, then all the UI — build one complete feature path at a time:
|
|
60
|
+
|
|
61
|
+
**Bad (horizontal slicing):**
|
|
62
|
+
```
|
|
63
|
+
Task 1: Build entire database schema
|
|
64
|
+
Task 2: Build all API endpoints
|
|
65
|
+
Task 3: Build all UI components
|
|
66
|
+
Task 4: Connect everything
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Good (vertical slicing):**
|
|
70
|
+
```
|
|
71
|
+
Task 1: User can create an account (schema + API + UI for registration)
|
|
72
|
+
Task 2: User can log in (auth schema + API + UI for login)
|
|
73
|
+
Task 3: User can create a task (task schema + API + UI for creation)
|
|
74
|
+
Task 4: User can view task list (query + API + UI for list view)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Each vertical slice delivers working, testable functionality.
|
|
78
|
+
|
|
79
|
+
### Step 4: Write Tasks
|
|
80
|
+
|
|
81
|
+
Each task follows this structure, whether it lands in the markdown task list or as an item in an external tracker (see Output Files):
|
|
82
|
+
|
|
83
|
+
```markdown
|
|
84
|
+
## Task [N]: [Short descriptive title]
|
|
85
|
+
|
|
86
|
+
**Description:** One paragraph explaining what this task accomplishes.
|
|
87
|
+
|
|
88
|
+
**Acceptance criteria:**
|
|
89
|
+
- [ ] [Specific, testable condition]
|
|
90
|
+
- [ ] [Specific, testable condition]
|
|
91
|
+
|
|
92
|
+
**Verification:**
|
|
93
|
+
- [ ] Tests pass: [the repository's focused-test command]
|
|
94
|
+
- [ ] Build succeeds: [the repository's build command]
|
|
95
|
+
- [ ] Manual check: [description of what to verify]
|
|
96
|
+
|
|
97
|
+
**Dependencies:** [Task numbers this depends on, or "None"]
|
|
98
|
+
|
|
99
|
+
**Files likely touched:**
|
|
100
|
+
- `src/path/to/file.ts`
|
|
101
|
+
- `tests/path/to/test.ts`
|
|
102
|
+
|
|
103
|
+
**Estimated scope:** [Small: 1-2 files | Medium: 3-5 files | Large: 5+ files]
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Step 5: Order and Checkpoint
|
|
107
|
+
|
|
108
|
+
Arrange tasks so that:
|
|
109
|
+
|
|
110
|
+
1. Dependencies are satisfied (build foundation first)
|
|
111
|
+
2. Each task leaves the system in a working state
|
|
112
|
+
3. Verification checkpoints occur after every 2-3 tasks
|
|
113
|
+
4. High-risk tasks are early (fail fast)
|
|
114
|
+
|
|
115
|
+
Add explicit checkpoints to the task list target:
|
|
116
|
+
|
|
117
|
+
```markdown
|
|
118
|
+
## Checkpoint: After Tasks 1-3
|
|
119
|
+
- [ ] All tests pass
|
|
120
|
+
- [ ] Application builds without errors
|
|
121
|
+
- [ ] Core user flow works end-to-end
|
|
122
|
+
- [ ] Review with human before proceeding
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Task Sizing Guidelines
|
|
126
|
+
|
|
127
|
+
| Size | Files | Scope | Example |
|
|
128
|
+
|------|-------|-------|---------|
|
|
129
|
+
| **XS** | 1 | Single function or config change | Add a validation rule |
|
|
130
|
+
| **S** | 1-2 | One component or endpoint | Add a new API endpoint |
|
|
131
|
+
| **M** | 3-5 | One feature slice | User registration flow |
|
|
132
|
+
| **L** | 5-8 | Multi-component feature | Search with filtering and pagination |
|
|
133
|
+
| **XL** | 8+ | **Too large — break it down further** | — |
|
|
134
|
+
|
|
135
|
+
If a task is L or larger, it should be broken into smaller tasks. An agent performs best on S and M tasks.
|
|
136
|
+
|
|
137
|
+
**When to break a task down further:**
|
|
138
|
+
- It would take more than one focused session (roughly 2+ hours of agent work)
|
|
139
|
+
- You cannot describe the acceptance criteria in 3 or fewer bullet points
|
|
140
|
+
- It touches two or more independent subsystems (e.g., auth and billing)
|
|
141
|
+
- You find yourself writing "and" in the task title (a sign it is two tasks)
|
|
142
|
+
|
|
143
|
+
## Output Files
|
|
144
|
+
|
|
145
|
+
- **Plan document:** Save the implementation plan to `tasks/plan.md`. This is always a markdown file — design decisions, risks, and open questions don't map cleanly onto individual tracker issues.
|
|
146
|
+
- **Task list:** Record each task in the **task list target** (defined below).
|
|
147
|
+
|
|
148
|
+
Create the `tasks/` directory if it does not exist.
|
|
149
|
+
|
|
150
|
+
**Never overwrite an incomplete plan.** Before writing `tasks/plan.md` or `tasks/todo.md`, check whether they already exist and still contain unchecked tasks:
|
|
151
|
+
|
|
152
|
+
- Same work being replanned (the user asked to revise or extend this plan) → update the existing files in place.
|
|
153
|
+
- Different work → **stop and ask.** The unchecked tasks may be mid-build in another session. Do not delete, overwrite, or rename the existing files on your own; present the conflict and let the user decide (finish the old plan first, explicitly discard it, or tell you where the new plan should go).
|
|
154
|
+
|
|
155
|
+
The same rule applies to an external task list target: never bulk-close or delete another plan's open tracker items to make room for new ones.
|
|
156
|
+
|
|
157
|
+
### Task List Target
|
|
158
|
+
|
|
159
|
+
The task list target is where tasks and checkpoints are recorded. It is defined once, here; every other reference in this skill defers to it.
|
|
160
|
+
|
|
161
|
+
- **Default: a checklist-style markdown file at `tasks/todo.md`.** This is the convention the `/build` command and other downstream tooling expect. Use it unless the project says otherwise.
|
|
162
|
+
- **External tracker:** if the project's agent rules (`CLAUDE.md`, `AGENTS.md`, etc.) or the user designate an issue tracker (e.g. GitHub Issues, Jira, Linear, `bd`/beads), create one tracker item per task instead of writing `tasks/todo.md`. Map the Step 4 structure onto the tracker's fields: acceptance criteria and verification steps in the item body, dependencies via the tracker's linking mechanism (`bd dep add`, "blocked by", etc.). Record Step 5 checkpoints as tracker items too, or as a checklist in the plan document if the tracker has no natural equivalent.
|
|
163
|
+
|
|
164
|
+
When using an external tracker, note it in `tasks/plan.md` (e.g. "Tasks tracked in Linear project FOO") so downstream steps and future sessions know where to look, and keep the plan document's Task List section as an ordered index of tracker item IDs or links rather than a duplicate checklist.
|
|
165
|
+
|
|
166
|
+
## Plan Document Template
|
|
167
|
+
|
|
168
|
+
```markdown
|
|
169
|
+
# Implementation Plan: [Feature/Project Name]
|
|
170
|
+
|
|
171
|
+
## Overview
|
|
172
|
+
[One paragraph summary of what we're building]
|
|
173
|
+
|
|
174
|
+
## Architecture Decisions
|
|
175
|
+
- [Key decision 1 and rationale]
|
|
176
|
+
- [Key decision 2 and rationale]
|
|
177
|
+
|
|
178
|
+
## Task List
|
|
179
|
+
|
|
180
|
+
### Phase 1: Foundation
|
|
181
|
+
- [ ] Task 1: ...
|
|
182
|
+
- [ ] Task 2: ...
|
|
183
|
+
|
|
184
|
+
### Checkpoint: Foundation
|
|
185
|
+
- [ ] Tests pass, builds clean
|
|
186
|
+
|
|
187
|
+
### Phase 2: Core Features
|
|
188
|
+
- [ ] Task 3: ...
|
|
189
|
+
- [ ] Task 4: ...
|
|
190
|
+
|
|
191
|
+
### Checkpoint: Core Features
|
|
192
|
+
- [ ] End-to-end flow works
|
|
193
|
+
|
|
194
|
+
### Phase 3: Polish
|
|
195
|
+
- [ ] Task 5: ...
|
|
196
|
+
- [ ] Task 6: ...
|
|
197
|
+
|
|
198
|
+
### Checkpoint: Complete
|
|
199
|
+
- [ ] All acceptance criteria met
|
|
200
|
+
- [ ] Ready for review
|
|
201
|
+
|
|
202
|
+
## Risks and Mitigations
|
|
203
|
+
| Risk | Impact | Mitigation |
|
|
204
|
+
|------|--------|------------|
|
|
205
|
+
| [Risk] | [High/Med/Low] | [Strategy] |
|
|
206
|
+
|
|
207
|
+
## Open Questions
|
|
208
|
+
- [Question needing human input]
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
When tasks live in an external tracker, keep the Task List section above as an ordered index of tracker item IDs or links instead of a duplicate checklist.
|
|
212
|
+
|
|
213
|
+
## Parallelization Opportunities
|
|
214
|
+
|
|
215
|
+
When multiple agents or sessions are available:
|
|
216
|
+
|
|
217
|
+
- **Safe to parallelize:** Independent feature slices, tests for already-implemented features, documentation
|
|
218
|
+
- **Must be sequential:** Database migrations, shared state changes, dependency chains
|
|
219
|
+
- **Needs coordination:** Features that share an API contract (define the contract first, then parallelize)
|
|
220
|
+
|
|
221
|
+
## Common Rationalizations
|
|
222
|
+
|
|
223
|
+
| Rationalization | Reality |
|
|
224
|
+
|---|---|
|
|
225
|
+
| "I'll figure it out as I go" | That's how you end up with a tangled mess and rework. 10 minutes of planning saves hours. |
|
|
226
|
+
| "The tasks are obvious" | Write them down anyway. Explicit tasks surface hidden dependencies and forgotten edge cases. |
|
|
227
|
+
| "Planning is overhead" | Planning is the task. Implementation without a plan is just typing. |
|
|
228
|
+
| "I can hold it all in my head" | Context windows are finite. Written plans survive session boundaries and compaction. |
|
|
229
|
+
| "The old `tasks/plan.md` is stale, I'll just replace it" | Unchecked tasks may be mid-build in another session. Overwriting them destroys work state that exists nowhere else. Stop and ask. |
|
|
230
|
+
|
|
231
|
+
## Red Flags
|
|
232
|
+
|
|
233
|
+
- Starting implementation without a written task list
|
|
234
|
+
- Overwriting a `tasks/plan.md` or `tasks/todo.md` that still has unchecked tasks for different work, without asking
|
|
235
|
+
- Writing `tasks/todo.md` when the project has designated an external tracker (or scattering tasks across both)
|
|
236
|
+
- Tasks that say "implement the feature" without acceptance criteria
|
|
237
|
+
- No verification steps in the plan
|
|
238
|
+
- All tasks are XL-sized
|
|
239
|
+
- No checkpoints between tasks
|
|
240
|
+
- Dependency order isn't considered
|
|
241
|
+
|
|
242
|
+
## Verification
|
|
243
|
+
|
|
244
|
+
Before starting implementation, confirm:
|
|
245
|
+
|
|
246
|
+
- [ ] Every task has acceptance criteria
|
|
247
|
+
- [ ] Every task has a verification step
|
|
248
|
+
- [ ] Task dependencies are identified and ordered correctly
|
|
249
|
+
- [ ] Tasks are recorded in the task list target (default `tasks/todo.md`)
|
|
250
|
+
- [ ] No pre-existing incomplete plan was overwritten without explicit user confirmation
|
|
251
|
+
- [ ] No task touches more than ~5 files
|
|
252
|
+
- [ ] Checkpoints exist between major phases
|
|
253
|
+
- [ ] The human has reviewed and approved the plan
|
|
254
|
+
|
|
255
|
+
## See Also
|
|
256
|
+
|
|
257
|
+
Acceptance criteria are per-task and answer "did we build the right thing?". They sit on top of the project-wide Definition of Done, the standing bar every task clears before it counts as done. See `../../references/definition-of-done.md`.
|