You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(skills): add performance engineering awareness to pb-plan and pb-build prompts
Absorb key insights from performance audit methodology into the system
prompts for both planning and building phases. All performance checks are
conditional — only applied when tasks touch data access, API endpoints,
or hot paths.
pb-plan (design phase):
- Codebase audit now flags performance-relevant patterns (caching layers,
query helpers, pagination utilities, batch processing helpers)
- Architecture decisions include brief performance impact assessment for
data access and hot path decisions
- Architectural Constraints section includes N+1 and over-fetching
examples as RFC 2119 constraints
- Non-Functional Goals template adds structured fields for database access,
caching, API payload, and hot paths
- Design template adds 5.8a Performance Impact Assessment table mapping
decisions to performance characteristics, risks, and mitigations
- Key Principles adds #23: Performance-aware design
- Edge cases section adds performance-aware planning guidance
pb-build (implementation phase):
- Generator workflow adds Performance Sanity Check step (step 9 for
BDD+TDD, step 8 for TDD-only) checking for N+1, eager loading,
over-fetching
- Implementer prompt adds 2i-a. Performance Sanity Check section with
specific checks for loops, eager loading, over-fetching, constraints
- Evaluator prompt adds performance red flags to code quality checks,
new Check E — Performance Sanity, and performance to verdict format
- Anti-pattern list adds N+1 queries and over-fetching as known
anti-patterns
Files changed:
- skills/pb-plan/SKILL.md
- skills/pb-plan/references/design_template.md
- skills/pb-plan/references/tasks_template.md
- skills/pb-build/SKILL.md
- skills/pb-build/references/implementer_prompt.md
- skills/pb-build/references/evaluator_prompt.md
8. **Performance Sanity Check (when applicable)** — Same checks as BDD+TDD tasks above.
235
+
9. **Scope Check** — Verify scope compliance.
228
236
229
237
**The Generator MUST end its output with exactly this signal (no extra text after it):**
230
238
@@ -617,6 +625,8 @@ The Evaluator should watch for these common agent mistakes:
617
625
|**Speculative features**| Adding caching, validation, notifications to a "save preferences" request | Build only what was asked; add later when needed |
618
626
|**Vague success criteria**| "I'll review and improve the code" | "Write test for bug X → make it pass → verify no regressions" |
619
627
|**Style drift**| Changing quote style, whitespace, or return logic while adding logging | Match existing code style exactly |
628
+
|**N+1 queries**| Looping with individual DB calls instead of batch/eager loading | Use eager loading, batch queries, or prefetch where the design specifies |
629
+
|**Over-fetching**| Returning all columns/fields when the consumer only needs a few | Return only required fields; document why wider payload is justified |
**This audit is mandatory.** List reusable components in `design.md` Section 3.3 and reference them in `tasks.md` task context.
114
115
115
116
6.**Extract the `Architecture Decision Snapshot`** — this is mandatory whenever the repo has `AGENTS.md` or architecture-oriented docs:
@@ -119,6 +120,7 @@ Subagent rules:
119
120
- All external dependencies must be routed **through interfaces or abstract classes** in the plan unless the existing repo explicitly establishes a different seam.
120
121
- Reuse existing repo decisions when available; add new decisions only when the requirement creates a genuine gap.
121
122
-**Apply the ponytail ladder** when evaluating patterns: prefer stdlib/native solutions over custom implementations. An interface with one implementation is a factory for one product — skip it. A config for a value that never changes is a constant — hardcode it.
123
+
-**Performance impact assessment:** For any architectural decision that touches data access, API boundaries, or hot paths, briefly note the expected performance characteristic (e.g., "O(n) queries acceptable for n<100" or "requires lazy loading to avoid N+1"). Do not write full performance specs — just flag the obvious wins and risks.
122
124
123
125
7.**Audit coding standards and simplification boundaries** — determine which style and maintainability rules the eventual implementation must follow:
124
126
- Infer language- and framework-specific standards from `AGENTS.md`, `CLAUDE.md`, and the live codebase. Only apply standards that are relevant to the current repo; do not copy unrelated JavaScript or React rules into Python work.
@@ -253,6 +255,8 @@ Write a **compact** design doc to `specs/<spec-dir>/design.md`. Only include sec
253
255
- Database interactions **MUST** use the existing ORM layer; raw SQL queries **MUST NOT** be introduced because they bypass the query builder's injection protection.
254
256
- API responses **SHOULD** maintain <200ms p99 latency; if exceeded, the task **MUST** include performance optimization before marking done.
255
257
- If an unhandled edge case is encountered, the Builder **MUST** halt and file a DCR; it **MUST NOT** silently fabricate error handling.
258
+
- Database queries **MUST NOT** introduce N+1 patterns; the Builder **SHOULD** use eager loading or batch queries where the data access pattern involves related entities.
259
+
- API responses **SHOULD** avoid over-fetching; return only fields the consumer needs, or document why a wider payload is justified.
256
260
257
261
## Behavior Traceability Matrix
258
262
@@ -339,6 +343,12 @@ stateDiagram-v2
339
343
340
344
Read `references/design_template.md` and fill every section fully. Write the result to `specs/<spec-dir>/design.md`.
341
345
346
+
**Performance awareness for full mode:** When filling the Non-Functional Goals section, explicitly consider:
347
+
- **Database access patterns:** Identify whether the feature introduces new queries and whether they risk N+1 or missing indexes.
348
+
- **Caching opportunities:** Note if responses or computations are cacheable, and whether existing caching infrastructure can be reused.
349
+
- **API payload size:** Flag if the feature returns large datasets and whether pagination or field selection is needed.
350
+
- **Hot path identification:** If the feature touches code that runs frequently (request handlers, loops, parsers), note expected throughput requirements.
Write a **scenario-driven task list** to `specs/<spec-dir>/tasks.md`. Tasks are organized by Feature scenarios, not by module. Even in lightweight mode, task IDs must remain in `Task X.Y` format so `pb-build` can track state reliably:
@@ -513,6 +523,7 @@ Please review the design and tasks. When ready, run /pb-build <feature-name> to
513
523
20.**Truthfulness over fluency.** If information is missing, state assumptions explicitly instead of fabricating specifics.
514
524
21.**Deterministic output quality.** Final docs should be implementation-ready, with no template artifacts left behind.
515
525
22.**No speculative architecture.** If a design component cannot be traced to a Feature scenario, remove it. Avoid building what isn't requested.
526
+
23.**Performance-aware design.** When architecture decisions touch data access, API boundaries, or hot paths, note the expected performance characteristic. Flag N+1 risks, over-fetching, and missing indexes during the codebase audit. Do not write full performance specs — just identify the obvious wins and risks.
516
527
517
528
---
518
529
@@ -547,3 +558,4 @@ Please review the design and tasks. When ready, run /pb-build <feature-name> to
547
558
-**High-variance logic with small example space:** Add property-test planning rather than relying only on hand-written examples.
548
559
-**Parser/protocol/unsafe work:** Treat fuzz planning as required unless you can justify why crash-safety risk is absent.
549
560
-**Performance-sensitive work:** Add benchmark planning only when the requirement or codebase indicates performance is part of the contract.
561
+
-**Performance-aware planning:** When the feature touches data access, API boundaries, or hot paths, flag obvious N+1 risks, over-fetching, and missing indexes during the codebase audit. Include performance constraints in `design.md` §Architectural Constraints when they are part of the contract. Do not write full performance specs for every task — just identify the obvious wins and risks.
-**Hot paths:**[Throughput requirements for frequently-executed code]
76
80
-**Reliability:** ...
77
81
-**Security:** ...
78
82
@@ -242,6 +246,14 @@ graph LR
242
246
-**DIP Check:** Identify the seams where dependencies must be inverted.
243
247
-**Dependency Injection Plan:** All external dependencies should flow through interfaces or abstract classes unless the repo already has a documented alternative seam.
244
248
249
+
### 5.8a Performance Impact Assessment
250
+
251
+
> For architectural decisions that touch data access, API boundaries, or hot paths. Keep it brief — flag obvious wins and risks, not a full performance spec.
|[e.g., "Use ORM for user queries"]|[e.g., "O(n) for n<100 users"]|[e.g., "N+1 if relations not eager-loaded"]|[e.g., "Use select_related/joinedload"]|
256
+
245
257
### 5.9 BDD/TDD Strategy
246
258
247
259
> Describe how this feature will use outside-in development. Define the business-facing Gherkin loop and the supporting TDD loop.
Copy file name to clipboardExpand all lines: skills/pb-plan/references/tasks_template.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,7 @@
26
26
-**Behavior Preservation Rule:** State whether each task preserves existing behavior or intentionally changes it; validate that with scenario and regression coverage.
27
27
-**Simplification Rule:** Apply the ponytail ladder (YAGNI → stdlib → native → existing dep → one-liner → minimum code) at every implementation decision. Mark deferrals with `ponytail:` comments naming the ceiling and upgrade path.
28
28
-**Clarity Guardrail:** Avoid planning dense or clever rewrites; where relevant, avoid nested ternary operators in favor of clearer branching.
29
+
-**Performance Guardrail:** For tasks touching data access or hot paths, the task context should note expected query patterns and any N+1 or over-fetching risks identified during planning.
6.[ ]**Runtime-Evidenced (when applicable):** Runtime logs and health/probe results are captured, or `N/A` is explicitly justified.
187
188
7.[ ]**Behavior-Preserved or Documented:** The task confirms behavior preservation or documents the intentional behavior change.
188
189
8.[ ]**Simplified Responsibly:** Cleanup stayed within the planned scope and improved readability rather than introducing clever compaction.
190
+
9.[ ]**Performance-Sound (when applicable):** No obvious N+1 queries, over-fetching, or missing eager loading for tasks touching data access or hot paths; or `N/A` is explicitly justified.
0 commit comments