opencastle 0.32.4 → 0.32.6
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/README.md +13 -3
- package/bin/cli.mjs +2 -0
- package/dist/cli/bootstrap.js +1 -1
- package/dist/cli/bootstrap.js.map +1 -1
- package/dist/cli/bootstrap.test.js +16 -0
- package/dist/cli/bootstrap.test.js.map +1 -1
- package/dist/cli/init.test.js +38 -0
- package/dist/cli/init.test.js.map +1 -1
- package/dist/cli/stack-config-update.test.js +18 -0
- package/dist/cli/stack-config-update.test.js.map +1 -1
- package/dist/cli/stack-config.d.ts.map +1 -1
- package/dist/cli/stack-config.js +1 -0
- package/dist/cli/stack-config.js.map +1 -1
- package/dist/cli/types.d.ts +1 -1
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/orchestrator/plugins/index.d.ts.map +1 -1
- package/dist/orchestrator/plugins/index.js +4 -0
- package/dist/orchestrator/plugins/index.js.map +1 -1
- package/dist/orchestrator/plugins/notion/config.d.ts +3 -0
- package/dist/orchestrator/plugins/notion/config.d.ts.map +1 -0
- package/dist/orchestrator/plugins/notion/config.js +46 -0
- package/dist/orchestrator/plugins/notion/config.js.map +1 -0
- package/dist/orchestrator/plugins/trello/config.d.ts +3 -0
- package/dist/orchestrator/plugins/trello/config.d.ts.map +1 -0
- package/dist/orchestrator/plugins/trello/config.js +43 -0
- package/dist/orchestrator/plugins/trello/config.js.map +1 -0
- package/dist/orchestrator/plugins/types.d.ts +1 -1
- package/dist/orchestrator/plugins/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/cli/bootstrap.test.ts +21 -0
- package/src/cli/bootstrap.ts +1 -1
- package/src/cli/init.test.ts +46 -0
- package/src/cli/stack-config-update.test.ts +20 -0
- package/src/cli/stack-config.ts +1 -0
- package/src/cli/types.ts +1 -1
- package/src/dashboard/node_modules/.vite/deps/_metadata.json +6 -6
- package/src/orchestrator/agents/api-designer.agent.md +25 -34
- package/src/orchestrator/agents/architect.agent.md +40 -84
- package/src/orchestrator/agents/content-engineer.agent.md +29 -31
- package/src/orchestrator/agents/copywriter.agent.md +35 -60
- package/src/orchestrator/agents/data-expert.agent.md +24 -30
- package/src/orchestrator/agents/database-engineer.agent.md +26 -31
- package/src/orchestrator/agents/developer.agent.md +32 -34
- package/src/orchestrator/agents/devops-expert.agent.md +31 -26
- package/src/orchestrator/agents/documentation-writer.agent.md +29 -29
- package/src/orchestrator/agents/performance-expert.agent.md +36 -33
- package/src/orchestrator/agents/release-manager.agent.md +25 -34
- package/src/orchestrator/agents/researcher.agent.md +41 -95
- package/src/orchestrator/agents/reviewer.agent.md +24 -34
- package/src/orchestrator/agents/security-expert.agent.md +35 -39
- package/src/orchestrator/agents/seo-specialist.agent.md +25 -32
- package/src/orchestrator/agents/session-guard.agent.md +20 -79
- package/src/orchestrator/agents/team-lead.agent.md +50 -254
- package/src/orchestrator/agents/testing-expert.agent.md +37 -49
- package/src/orchestrator/agents/ui-ux-expert.agent.md +33 -39
- package/src/orchestrator/customizations/KNOWN-ISSUES.md +0 -1
- package/src/orchestrator/customizations/agents/skill-matrix.json +20 -4
- package/src/orchestrator/customizations/agents/skill-matrix.md +20 -0
- package/src/orchestrator/instructions/general.instructions.md +24 -84
- package/src/orchestrator/plugins/astro/SKILL.md +23 -179
- package/src/orchestrator/plugins/convex/SKILL.md +38 -12
- package/src/orchestrator/plugins/index.ts +4 -0
- package/src/orchestrator/plugins/netlify/SKILL.md +17 -13
- package/src/orchestrator/plugins/nextjs/SKILL.md +55 -261
- package/src/orchestrator/plugins/notion/SKILL.md +205 -0
- package/src/orchestrator/plugins/notion/config.ts +47 -0
- package/src/orchestrator/plugins/nx/SKILL.md +20 -72
- package/src/orchestrator/plugins/playwright/SKILL.md +5 -17
- package/src/orchestrator/plugins/slack/SKILL.md +28 -190
- package/src/orchestrator/plugins/teams/SKILL.md +10 -140
- package/src/orchestrator/plugins/trello/SKILL.md +151 -0
- package/src/orchestrator/plugins/trello/config.ts +44 -0
- package/src/orchestrator/plugins/types.ts +1 -1
- package/src/orchestrator/plugins/vitest/SKILL.md +2 -2
- package/src/orchestrator/prompts/bug-fix.prompt.md +25 -63
- package/src/orchestrator/prompts/implement-feature.prompt.md +29 -66
- package/src/orchestrator/prompts/quick-refinement.prompt.md +31 -66
- package/src/orchestrator/skills/accessibility-standards/SKILL.md +50 -105
- package/src/orchestrator/skills/agent-hooks/SKILL.md +60 -110
- package/src/orchestrator/skills/agent-memory/SKILL.md +44 -93
- package/src/orchestrator/skills/api-patterns/SKILL.md +20 -68
- package/src/orchestrator/skills/code-commenting/SKILL.md +49 -101
- package/src/orchestrator/skills/context-map/SKILL.md +47 -88
- package/src/orchestrator/skills/data-engineering/SKILL.md +27 -74
- package/src/orchestrator/skills/decomposition/SKILL.md +50 -98
- package/src/orchestrator/skills/deployment-infrastructure/SKILL.md +44 -107
- package/src/orchestrator/skills/documentation-standards/SKILL.md +28 -89
- package/src/orchestrator/skills/fast-review/SKILL.md +51 -276
- package/src/orchestrator/skills/frontend-design/SKILL.md +53 -163
- package/src/orchestrator/skills/git-workflow/SKILL.md +18 -54
- package/src/orchestrator/skills/memory-merger/SKILL.md +51 -88
- package/src/orchestrator/skills/observability-logging/SKILL.md +29 -75
- package/src/orchestrator/skills/orchestration-protocols/SKILL.md +58 -117
- package/src/orchestrator/skills/panel-majority-vote/SKILL.md +65 -140
- package/src/orchestrator/skills/performance-optimization/SKILL.md +21 -85
- package/src/orchestrator/skills/project-consistency/SKILL.md +62 -281
- package/src/orchestrator/skills/react-development/SKILL.md +38 -86
- package/src/orchestrator/skills/security-hardening/SKILL.md +40 -84
- package/src/orchestrator/skills/self-improvement/SKILL.md +26 -60
- package/src/orchestrator/skills/seo-patterns/SKILL.md +40 -105
- package/src/orchestrator/skills/session-checkpoints/SKILL.md +26 -68
- package/src/orchestrator/skills/team-lead-reference/SKILL.md +66 -206
- package/src/orchestrator/skills/testing-workflow/SKILL.md +42 -112
- package/src/orchestrator/skills/validation-gates/SKILL.md +39 -170
- package/src/orchestrator/snippets/base-output-contract.md +14 -0
- package/src/orchestrator/snippets/discovered-issues-policy.md +15 -0
- package/src/orchestrator/snippets/logging-mandatory.md +11 -0
- package/src/orchestrator/snippets/never-expose-secrets.md +22 -0
|
@@ -9,173 +9,114 @@ Runtime patterns for managing delegated agents. **Load at:** Execution phase (St
|
|
|
9
9
|
|
|
10
10
|
## Active Steering
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Intervene early when you spot:
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
| Signal | Action |
|
|
15
|
+
|--------|--------|
|
|
16
|
+
| Failing tests/builds | Can't resolve dependency or breaks existing code |
|
|
17
|
+
| Unexpected file changes | Files outside partition in diff |
|
|
18
|
+
| Scope creep | Refactors code not in scope |
|
|
19
|
+
| Circular behavior | Same failing approach retried without change |
|
|
20
|
+
| Intent misunderstanding | Session log shows wrong prompt interpretation |
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
When redirecting, explain *why* and *how*:
|
|
21
23
|
|
|
22
|
-
> "Don't modify `libs/data/src/lib/product.ts` —
|
|
24
|
+
> "Don't modify `libs/data/src/lib/product.ts` — shared across features. Add the new query in `libs/data/src/lib/reviews.ts`."
|
|
23
25
|
|
|
24
|
-
**
|
|
25
|
-
|
|
26
|
-
**Background agent caveat:** The drift signals above apply only to **sub-agents** (inline) where you see results in real-time. Background agents run autonomously — you cannot inspect their intermediate state or redirect mid-execution. For background agents, steering is **post-hoc**: invest more effort in prompt specificity and file partition constraints upfront, then review thoroughly when the agent returns its output.
|
|
26
|
+
**Sub-agents:** Catch problems early (5 min in can save an hour). **Background agents:** Steer post-hoc — invest in prompt specificity and partition constraints upfront.
|
|
27
27
|
|
|
28
28
|
## Background Agents
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
Run autonomously in isolated Git worktrees. Reserve for well-scoped tasks >5 min with clear acceptance criteria.
|
|
31
31
|
|
|
32
32
|
- **Spawn:** Delegate Session → Background → Select agent → Enter prompt
|
|
33
|
-
- **Auto-compaction:** At 95% token limit
|
|
34
|
-
- **
|
|
35
|
-
- **Duration threshold:** Reserve for tasks expected to take >5 minutes
|
|
36
|
-
- **No real-time monitoring:** You cannot inspect intermediate state. Drift detection happens only at completion review. Mitigate with: (a) highly specific prompts, (b) strict file partition constraints, (c) acceptance criteria checklists in the prompt
|
|
33
|
+
- **Auto-compaction:** At 95% token limit; use `--resume` to continue
|
|
34
|
+
- **No real-time monitoring:** Invest in specific prompts, strict partition constraints, and acceptance criteria checklists upfront
|
|
37
35
|
|
|
38
36
|
## Parallel Research Protocol
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
### When to Use
|
|
43
|
-
|
|
44
|
-
- 3+ independent research questions need answering before implementation can begin
|
|
45
|
-
- Broad codebase exploration across multiple libraries or domains
|
|
46
|
-
- Multi-area analysis (e.g., "How do we handle X in the frontend, backend, and CMS?")
|
|
38
|
+
Spawn multiple research sub-agents in parallel when 3+ independent questions must be answered before implementation. **Use when:** 3+ independent research questions, broad codebase exploration, or multi-area analysis (frontend/backend/CMS). **Skip when:** single-file investigation, answer in one known location, sequential results, or fewer than 3 questions.
|
|
47
39
|
|
|
48
40
|
### Spawn Strategy
|
|
49
41
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
| Rule | Detail |
|
|
43
|
+
|------|--------|
|
|
44
|
+
| Divide by topic/area | Each researcher owns a coherent domain |
|
|
45
|
+
| Max 3–5 researchers | More creates diminishing returns and token waste |
|
|
46
|
+
| Focused scope per agent | Explicit dirs, file patterns, or questions |
|
|
47
|
+
| Economy/Standard tier | Manage cost for research sub-agents |
|
|
56
48
|
|
|
49
|
+
**Prompt template:**
|
|
57
50
|
```
|
|
58
51
|
Research: [specific question]
|
|
59
52
|
Scope: [files/directories to search]
|
|
60
|
-
Return:
|
|
61
|
-
- Key findings (bullet list)
|
|
62
|
-
- Relevant file paths (with line numbers)
|
|
63
|
-
- Patterns observed
|
|
64
|
-
- Unanswered questions
|
|
53
|
+
Return: key findings, relevant file paths (with line numbers), patterns, unanswered questions
|
|
65
54
|
```
|
|
66
55
|
|
|
67
56
|
### Result Merge Protocol
|
|
68
57
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
3. **Resolve conflicts** — if agents report contradictory information, trust the one with more specific evidence (exact file paths + line numbers > general observations)
|
|
74
|
-
4. **Synthesize** into a single context block for the next phase — distill the combined findings into a concise summary that can be included in implementation delegation prompts
|
|
75
|
-
|
|
76
|
-
### When NOT to Use
|
|
77
|
-
|
|
78
|
-
- Single-file investigation — just read the file directly
|
|
79
|
-
- When the answer is in one known location — a single sub-agent or direct read is faster
|
|
80
|
-
- When results must be sequential (e.g., "find X, then based on X find Y")
|
|
81
|
-
- For fewer than 3 questions — overhead of parallel coordination exceeds time saved
|
|
58
|
+
1. Collect all results into single context
|
|
59
|
+
2. Deduplicate (same file/pattern counts once)
|
|
60
|
+
3. Resolve conflicts — specific evidence beats general observations
|
|
61
|
+
4. Synthesize into concise context block for implementation prompts
|
|
82
62
|
|
|
83
63
|
## Batch Reviews
|
|
84
64
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
-
|
|
88
|
-
- Run fast reviews in parallel for independent outputs
|
|
89
|
-
- If multiple outputs share the same file partition boundary, review them sequentially to catch integration issues
|
|
90
|
-
- For panel reviews, combine related artifacts into a single panel question when they share acceptance criteria
|
|
65
|
+
- Group by domain (UI, data); run fast reviews in parallel for independent outputs
|
|
66
|
+
- Review sequentially when outputs share the same partition boundary
|
|
67
|
+
- Combine related artifacts into one panel question when they share acceptance criteria
|
|
91
68
|
|
|
92
69
|
## Context Compaction
|
|
93
70
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
**When:** Multi-phase chains where the next agent only needs outcomes, not full reasoning traces. Skip for single-phase work or when raw detail is needed (e.g., code review).
|
|
97
|
-
|
|
98
|
-
**How:** After a sub-agent returns, extract only: files changed, key decisions, verification results (pass/fail), and blockers. Discard raw tool output, reasoning traces, and failed attempts.
|
|
99
|
-
|
|
100
|
-
**Template for delegation prompts:**
|
|
71
|
+
Summarize prior phase output before passing to the next agent. **Extract:** files changed, key decisions, verification (pass/fail), blockers. **Discard:** raw tool output, reasoning traces, failed attempts.
|
|
101
72
|
|
|
73
|
+
**Template:**
|
|
102
74
|
```
|
|
103
75
|
### Prior Phase Output
|
|
104
76
|
**Phase [N] — [Agent Name] — [Task Title]**
|
|
105
|
-
- Files changed: [list
|
|
106
|
-
- Decisions: [key decisions
|
|
77
|
+
- Files changed: [list]
|
|
78
|
+
- Decisions: [key decisions affecting downstream work]
|
|
107
79
|
- Verification: [lint ✅ | types ✅ | tests ✅]
|
|
108
80
|
- Blockers: [none | list]
|
|
109
81
|
```
|
|
110
82
|
|
|
111
|
-
## Agent Health
|
|
112
|
-
|
|
113
|
-
Monitor delegated agents for failure signals. Intervene early rather than waiting for completion.
|
|
83
|
+
## Agent Health Monitoring
|
|
114
84
|
|
|
115
85
|
### Health Signals
|
|
116
86
|
|
|
117
|
-
| Signal |
|
|
118
|
-
|
|
119
|
-
| **Stuck**
|
|
120
|
-
| **Looping**
|
|
121
|
-
| **Scope creep**
|
|
122
|
-
| **Context exhaustion**
|
|
123
|
-
| **Permission loop**
|
|
124
|
-
|
|
125
|
-
### Health-Check Cadence
|
|
87
|
+
| Signal | Threshold | Recovery |
|
|
88
|
+
|--------|-----------|----------|
|
|
89
|
+
| **Stuck** — no output/changes | Sub: 5 min / BG: 15 min | Nudge; if frozen, abort + re-delegate with simpler scope |
|
|
90
|
+
| **Looping** — same error repeated | 3 consecutive failures | Abort; add context; re-delegate with explicit fix path |
|
|
91
|
+
| **Scope creep** — files outside partition | Any | Redirect: "Only modify files in [partition]. Revert [file]." |
|
|
92
|
+
| **Context exhaustion** — confused/repetitive | Visible instruction amnesia | Checkpoint, end session, resume in fresh context |
|
|
93
|
+
| **Permission loop** — waiting for input | 2+ prompts without progress | Auto-approve if safe; abort + re-delegate |
|
|
126
94
|
|
|
127
|
-
|
|
128
|
-
- **Background agents:** Check terminal output after 10 minutes, then every 10 minutes
|
|
129
|
-
- **After completion:** Always review the full diff before accepting output
|
|
95
|
+
**Cadence:** Sub-agents — continuous (real-time). Background agents — check at 10 min, then every 10 min. Always review full diff before accepting.
|
|
130
96
|
|
|
131
97
|
### Escalation Path
|
|
132
98
|
|
|
133
|
-
1. **
|
|
134
|
-
2. **
|
|
135
|
-
3. **
|
|
99
|
+
1. **Failure 1:** Re-delegate with more specific prompt + error context
|
|
100
|
+
2. **Failure 2:** Downscope (split into smaller pieces), re-delegate
|
|
101
|
+
3. **Failure 3:** Log to `.opencastle/AGENT-FAILURES.md`; if 3× panel BLOCK or conflict, create dispute in `.opencastle/DISPUTES.md` (see **team-lead-reference** § Dispute Protocol)
|
|
136
102
|
|
|
137
103
|
## Error Recovery Playbook
|
|
138
104
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
**
|
|
144
|
-
**
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
**Symptom:** Tool calls fail with connection or timeout errors.
|
|
149
|
-
**Recovery:** (1) Check if the MCP server is running. (2) If transient, retry once. (3) If persistent, work around: use CLI tools as alternatives. Log to DLQ if critical.
|
|
150
|
-
|
|
151
|
-
### Background Agent Produces Broken Output
|
|
152
|
-
|
|
153
|
-
**Symptom:** Background agent returns, but files have lint/type/test errors.
|
|
154
|
-
**Recovery:** (1) Review the diff to understand intent. (2) If fixable with small edits, fix inline. (3) If fundamentally wrong, discard the worktree changes and re-delegate with a more specific prompt. (4) Log to DLQ after 2 failed attempts.
|
|
155
|
-
|
|
156
|
-
### Merge Conflict from Parallel Agents
|
|
157
|
-
|
|
158
|
-
**Symptom:** Two background agents modified overlapping files.
|
|
159
|
-
**Recovery:** (1) This should never happen if file partitioning was followed. (2) Accept one agent's changes first (the one with more complex work). (3) Re-delegate the simpler changes to adapt to the new state. (4) Use the **self-improvement** skill to add a lesson about the conflict.
|
|
160
|
-
|
|
161
|
-
### Context Window Exhausted
|
|
162
|
-
|
|
163
|
-
**Symptom:** Agent responses become confused, repetitive, or lose track of earlier instructions.
|
|
164
|
-
**Recovery:** (1) Save a session checkpoint immediately. (2) End the current session. (3) Resume in a new session, loading the checkpoint. (4) Reduce parallel work in the next session.
|
|
165
|
-
|
|
166
|
-
### Test Failures After Merge
|
|
167
|
-
|
|
168
|
-
**Symptom:** Tests pass individually but fail when multiple agent outputs are merged.
|
|
169
|
-
**Recovery:** (1) Run affected tests to identify which projects break. (2) Check for import conflicts, duplicate definitions, or state pollution. (3) Delegate fix to the agent whose changes are most likely the cause.
|
|
105
|
+
| Failure | Symptom | Recovery |
|
|
106
|
+
|---------|---------|----------|
|
|
107
|
+
| **Retry loop** | Same command fails 3+ times | Abort; identify root cause; re-delegate with explicit fix; log lesson |
|
|
108
|
+
| **MCP unavailable** | Tool connection/timeout errors | Check server; retry once; fall back to CLI; log to DLQ if critical |
|
|
109
|
+
| **Broken BG output** | Lint/type/test errors on return | Fix inline if small; discard + re-delegate if fundamental; DLQ after 2 fails |
|
|
110
|
+
| **Parallel merge conflict** | Two agents modified overlapping files | Accept complex side first; re-delegate simple side to adapt; log lesson |
|
|
111
|
+
| **Context exhausted** | Confused/repetitive responses | Checkpoint; end session; resume with checkpoint; reduce parallel work |
|
|
112
|
+
| **Post-merge test failure** | Tests pass alone but fail merged | Run affected tests; check import/state conflicts; delegate fix to likely cause |
|
|
170
113
|
|
|
171
114
|
## Agent Circuit Breaker
|
|
172
115
|
|
|
173
|
-
Track per-agent failure counts across the session (not just per-task). If the same agent keeps failing, the problem is likely systemic.
|
|
174
|
-
|
|
175
116
|
| Threshold | Action |
|
|
176
117
|
|-----------|--------|
|
|
177
|
-
| **2 failures** |
|
|
178
|
-
| **3 failures** | Open circuit — stop delegating
|
|
179
|
-
| **Next session** | Half-open —
|
|
118
|
+
| **2 failures** | Investigate: same error class? Model healthy? Prompt pattern? |
|
|
119
|
+
| **3 failures** | Open circuit — stop delegating; reassign or escalate to user |
|
|
120
|
+
| **Next session** | Half-open — resets; re-open + add lesson if fails again |
|
|
180
121
|
|
|
181
|
-
|
|
122
|
+
Judgment-based, not a hard gate. 3 similar failures with the same error is more concerning than 3 unrelated failures.
|
|
@@ -3,168 +3,98 @@ name: panel-majority-vote
|
|
|
3
3
|
description: "Run 3 isolated reviewer sub-agents against the same question and decide PASS/BLOCK by majority vote (2/3 wins). Use when deterministic verification is insufficient."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
# Skill: Panel majority vote
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
## Contract
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
| Rule | Detail |
|
|
11
|
+
|------|--------|
|
|
12
|
+
| Scope | One run root, one panel key |
|
|
13
|
+
| Artifacts | Reviewers use only declared in-scope artifacts |
|
|
14
|
+
| Runners | Exactly 3 isolated reviewer runs |
|
|
15
|
+
| Verdict | Majority (2/3 wins) |
|
|
16
|
+
| On BLOCK | Consolidated report must include retry summary |
|
|
11
17
|
|
|
12
|
-
##
|
|
13
|
-
- Scope is exactly one run root and one panel key.
|
|
14
|
-
- Reviewers must only use the declared in-scope artifacts.
|
|
15
|
-
- Exactly 3 isolated reviewer runs.
|
|
16
|
-
- Majority vote decides overall verdict (2/3 wins).
|
|
17
|
-
- Consolidated panel report must include a short retry summary when BLOCK.
|
|
18
|
-
|
|
19
|
-
## Inputs
|
|
20
|
-
- Run root: `<runRoot>`
|
|
21
|
-
- Panel key: `<panelKey>` (a filesystem-safe identifier used to name output files)
|
|
22
|
-
- Exact question text (single question)
|
|
23
|
-
- Explicit in-scope artifact list (all under the same run root)
|
|
24
|
-
|
|
25
|
-
Optional (defaults shown):
|
|
26
|
-
- Panel output directory: `<panelDir>` (default: `<runRoot>/panel/`)
|
|
27
|
-
|
|
28
|
-
## Outputs (files)
|
|
29
|
-
- (Optional) Prompt payload: `<panelDir>/<panelKey>-panel-prompt.md`
|
|
30
|
-
- Raw reviewer outputs: `<panelDir>/<panelKey>-reviewer-outputs.md`
|
|
31
|
-
- Consolidated report: `<panelDir>/<panelKey>.md`
|
|
32
|
-
|
|
33
|
-
## Procedure (required: run in isolation)
|
|
34
|
-
Run this skill in an isolated subagent (using `runSubagent`) so the panel cannot accidentally consult unrelated workspace context.
|
|
35
|
-
|
|
36
|
-
The isolated runner subagent must:
|
|
37
|
-
1. Validate scope
|
|
38
|
-
- Ensure every in-scope artifact path is under `<runRoot>`.
|
|
39
|
-
- Ensure the in-scope list is sufficient to answer the question.
|
|
40
|
-
|
|
41
|
-
2. Spawn exactly 3 reviewers (in parallel)
|
|
42
|
-
- Launch 3 isolated reviewer subagents (using `runSubagent`) with the exact same prompt payload.
|
|
43
|
-
- The prompt payload may be passed directly to the reviewer subagents (no file required).
|
|
44
|
-
- If you want an explicit artifact of the prompt payload, optionally write it to `<panelDir>/<panelKey>-panel-prompt.md`.
|
|
45
|
-
- Reviewer prompt must require this strict output format:
|
|
46
|
-
1) VERDICT: PASS | BLOCK
|
|
47
|
-
2) MUST-FIX:
|
|
48
|
-
- ...
|
|
49
|
-
3) SHOULD-FIX:
|
|
50
|
-
- ...
|
|
51
|
-
4) QUESTIONS:
|
|
52
|
-
- ...
|
|
53
|
-
5) TEST IDEAS:
|
|
54
|
-
- ...
|
|
55
|
-
6) CONFIDENCE: low | med | high
|
|
56
|
-
- Reviewers must not include any other sections.
|
|
57
|
-
|
|
58
|
-
3. Persist reviewer outputs (required audit trail)
|
|
59
|
-
- Create/overwrite `<panelDir>/<panelKey>-reviewer-outputs.md`.
|
|
60
|
-
- Include at the top:
|
|
61
|
-
- Run root
|
|
62
|
-
- Panel key
|
|
63
|
-
- Question text
|
|
64
|
-
- In-scope artifact list
|
|
65
|
-
- (Optional) The exact prompt payload text provided to reviewers
|
|
66
|
-
- Then include each reviewer output verbatim, clearly separated.
|
|
67
|
-
|
|
68
|
-
4. Consolidate by majority vote (2/3 wins)
|
|
69
|
-
- Compute:
|
|
70
|
-
- PASS count
|
|
71
|
-
- BLOCK count
|
|
72
|
-
- Overall = PASS if PASS >= 2 else BLOCK
|
|
73
|
-
- Deduplicate MUST-FIX and SHOULD-FIX items; annotate how many reviewers flagged each.
|
|
74
|
-
- Record disagreements (items flagged by only 1 reviewer; or materially conflicting assessments).
|
|
75
|
-
- Include determinize-next recommendations.
|
|
76
|
-
- If Overall = BLOCK, include a short Retry summary:
|
|
77
|
-
- top changes required before retrying
|
|
78
|
-
|
|
79
|
-
5. Write the consolidated panel report
|
|
80
|
-
- Create `<panelDir>/<panelKey>.md` using the template in `panel-report.template.md` (in this directory).
|
|
81
|
-
|
|
82
|
-
6. Print a concise summary to chat
|
|
83
|
-
- Overall verdict + vote tally + path to `<panelDir>/<panelKey>.md`.
|
|
84
|
-
|
|
85
|
-
7. Log the panel result **(⛔ hard gate — do NOT return the verdict or proceed until logged)**
|
|
86
|
-
- Log the panel result using the **observability-logging** skill's panel record command. An unlogged panel is a failed panel.
|
|
87
|
-
- Include: `panel_key`, `verdict`, `pass_count`, `block_count`, `must_fix`, `should_fix`, `reviewer_model`, `weighted`, `attempt`, `tracker_issue`, `artifacts_count`, `report_path`.
|
|
88
|
-
- The skill's panel record command includes a verify step.
|
|
89
|
-
|
|
90
|
-
Finally: ensure whatever produced the claim being verified links the consolidated panel report as verification evidence.
|
|
18
|
+
## Inputs / Outputs
|
|
91
19
|
|
|
92
|
-
|
|
93
|
-
- If the panel output is BLOCK, prefer to change the underlying work and re-run the same panel question over re-wording the question.
|
|
94
|
-
- After 3 consecutive BLOCKs on the same panel key, create a **dispute record** in `.opencastle/DISPUTES.md` instead of retrying further. The dispute packages the agent's position, all reviewer feedback, attempt history, and resolution options for human decision-making. See the **team-lead-reference** skill § Dispute Protocol for the full procedure.
|
|
20
|
+
**Inputs:** `<runRoot>`, `<panelKey>` (filesystem-safe), question text, artifact list. Panel dir default: `<runRoot>/panel/`.
|
|
95
21
|
|
|
96
|
-
|
|
22
|
+
| File | Path |
|
|
23
|
+
|------|------|
|
|
24
|
+
| Prompt payload (optional) | `<panelDir>/<panelKey>-panel-prompt.md` |
|
|
25
|
+
| Raw reviewer outputs | `<panelDir>/<panelKey>-reviewer-outputs.md` |
|
|
26
|
+
| Consolidated report | `<panelDir>/<panelKey>.md` |
|
|
97
27
|
|
|
98
|
-
|
|
99
|
-
- **Security, architecture, complex logic** → Quality (Claude Sonnet 4.6) for all 3 reviewers
|
|
100
|
-
- **Feature implementation, UI, queries** → Standard (Gemini 3.1 Pro) for all 3 reviewers
|
|
101
|
-
- **Mixed-domain review** → Use Quality for at least 1 reviewer, Standard for the other 2
|
|
28
|
+
## Procedure
|
|
102
29
|
|
|
103
|
-
|
|
30
|
+
1. **Validate scope** — every artifact path is under `<runRoot>`; list is sufficient to answer the question.
|
|
31
|
+
2. **Spawn 3 reviewers in parallel** — identical prompt to 3 isolated subagents. Optionally write payload to `<panelDir>/<panelKey>-panel-prompt.md`. Required output sections (no others): `VERDICT: PASS | BLOCK`, `MUST-FIX:`, `SHOULD-FIX:`, `QUESTIONS:`, `TEST IDEAS:`, `CONFIDENCE: low | med | high`.
|
|
32
|
+
3. **Persist outputs** — write `<panelDir>/<panelKey>-reviewer-outputs.md` with header (run root, panel key, question, artifacts) and each reviewer output verbatim, separated.
|
|
33
|
+
4. **Consolidate** — count PASS/BLOCK; overall PASS if ≥ 2. Deduplicate MUST-FIX/SHOULD-FIX with reviewer counts. Record disagreements. Include determinize-next recs. If BLOCK, add retry summary.
|
|
34
|
+
5. **Write report** — create `<panelDir>/<panelKey>.md` using `panel-report.template.md`.
|
|
35
|
+
6. **Print summary** — overall verdict + vote tally + report path.
|
|
36
|
+
7. **Log (⛔ hard gate)** — use **observability-logging** skill panel command. Fields: `panel_key`, `verdict`, `pass_count`, `block_count`, `must_fix`, `should_fix`, `reviewer_model`, `weighted`, `attempt`, `tracker_issue`, `artifacts_count`, `report_path`. Link report as verification evidence.
|
|
104
37
|
|
|
105
|
-
##
|
|
38
|
+
## Notes
|
|
39
|
+
|
|
40
|
+
- On BLOCK: change the underlying work and re-run; do not re-word the question.
|
|
41
|
+
- After 3 consecutive BLOCKs on the same panel key: create a dispute record per **team-lead-reference** § Dispute Protocol.
|
|
106
42
|
|
|
107
|
-
|
|
43
|
+
## Model Selection
|
|
108
44
|
|
|
109
|
-
|
|
45
|
+
| Domain | Model |
|
|
46
|
+
|--------|-------|
|
|
47
|
+
| Security, architecture, complex logic | Quality (Claude Sonnet 4.6) × 3 |
|
|
48
|
+
| Feature implementation, UI, queries | Standard (Gemini 3.1 Pro) × 3 |
|
|
49
|
+
| Mixed-domain | Quality × 1, Standard × 2 |
|
|
110
50
|
|
|
111
|
-
|
|
112
|
-
|--------------|--------------------|-----------------------|
|
|
113
|
-
| Security vulnerability present? | ✅ | — |
|
|
114
|
-
| Code correctness | ✅ | — |
|
|
115
|
-
| Best UI approach for user experience | — | ✅ |
|
|
116
|
-
| Architecture tradeoff (performance vs maintainability) | — | ✅ |
|
|
117
|
-
| Data model design choices | — | ✅ |
|
|
118
|
-
| Naming conventions / code style disputes | — | ✅ |
|
|
51
|
+
Use same model for all 3 reviewers.
|
|
119
52
|
|
|
120
|
-
|
|
53
|
+
## Weighted Consensus Variant
|
|
121
54
|
|
|
122
|
-
|
|
55
|
+
For subjective decisions where domain expertise should weight more than head-count.
|
|
123
56
|
|
|
124
|
-
|
|
125
|
-
|--------|-------------|---------|
|
|
126
|
-
| **Domain expertise** | +2 | Security Expert reviewing auth code |
|
|
127
|
-
| **Confidence level** | +1 (high) / 0 (med) / -1 (low) | Self-reported by reviewer |
|
|
128
|
-
| **Prior success** | +1 | Agent has >80% success rate for similar reviews (from AGENT-PERFORMANCE.md) |
|
|
57
|
+
### When to Use
|
|
129
58
|
|
|
130
|
-
|
|
59
|
+
| Decision Type | Mode |
|
|
60
|
+
|--------------|------|
|
|
61
|
+
| Security vulnerability, code correctness | Simple majority |
|
|
62
|
+
| UI/UX, architecture tradeoffs, data model, naming | Weighted |
|
|
131
63
|
|
|
132
|
-
|
|
64
|
+
### Weight Assignment
|
|
133
65
|
|
|
134
|
-
|
|
135
|
-
Reviewer 1 (Security Expert, reviewing auth): base 1 + domain 2 + confidence 1 = weight 4
|
|
136
|
-
Reviewer 2 (Frontend Dev, reviewing auth): base 1 + domain 0 + confidence 1 = weight 2
|
|
137
|
-
Reviewer 3 (Architect, reviewing auth): base 1 + domain 1 + confidence 0 = weight 2
|
|
138
|
-
```
|
|
66
|
+
Base weight: 1. Add bonuses:
|
|
139
67
|
|
|
140
|
-
|
|
68
|
+
| Factor | Bonus |
|
|
69
|
+
|--------|-------|
|
|
70
|
+
| Domain expertise (relevant to review) | +2 |
|
|
71
|
+
| Confidence high / med / low | +1 / 0 / -1 |
|
|
72
|
+
| Prior success rate >80% (AGENT-PERFORMANCE.md) | +1 |
|
|
141
73
|
|
|
142
|
-
|
|
143
|
-
2. **Spawn reviewers** with the same prompt as simple majority (use the existing procedure)
|
|
144
|
-
3. **Collect verdicts** — each reviewer submits PASS/BLOCK with confidence level
|
|
145
|
-
4. **Calculate weighted score:**
|
|
146
|
-
- Sum weights of PASS reviewers → PASS score
|
|
147
|
-
- Sum weights of BLOCK reviewers → BLOCK score
|
|
148
|
-
- Overall = PASS if PASS score > BLOCK score, else BLOCK
|
|
149
|
-
5. **Tie-breaking:** If scores are equal, the reviewer with the highest individual weight breaks the tie. If weights are also equal, default to BLOCK (conservative).
|
|
74
|
+
Example: Security Expert + high = **4**; Architect + med = **2**.
|
|
150
75
|
|
|
151
|
-
###
|
|
76
|
+
### Voting Protocol
|
|
152
77
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
78
|
+
1. Assign weights before spawning.
|
|
79
|
+
2. Spawn with same prompt; collect PASS/BLOCK + confidence.
|
|
80
|
+
3. Score: sum weights by verdict; PASS if PASS score > BLOCK score.
|
|
81
|
+
4. Tie: highest individual weight breaks tie; if equal, default BLOCK.
|
|
156
82
|
|
|
157
|
-
###
|
|
83
|
+
### Conflict Resolution
|
|
84
|
+
|
|
85
|
+
| Scenario | Outcome |
|
|
86
|
+
|----------|---------|
|
|
87
|
+
| Low-weight BLOCKs, high-weight PASSes | PASS; move BLOCK's MUST-FIX → SHOULD-FIX |
|
|
88
|
+
| Domain expert BLOCKs, generalists PASS | BLOCK |
|
|
89
|
+
| All equal weight | Simple majority (2/3 wins) |
|
|
158
90
|
|
|
159
|
-
|
|
91
|
+
### Report Extension
|
|
160
92
|
|
|
161
93
|
```markdown
|
|
162
94
|
### Weighting
|
|
163
95
|
| Reviewer | Role | Domain | Confidence | Prior Success | Final Weight |
|
|
164
96
|
|----------|------|--------|------------|---------------|-------------|
|
|
165
97
|
| 1 | [Agent] | +X | +X | +X | X |
|
|
166
|
-
| 2 | [Agent] | +X | +X | +X | X |
|
|
167
|
-
| 3 | [Agent] | +X | +X | +X | X |
|
|
168
98
|
|
|
169
99
|
### Weighted Score
|
|
170
100
|
- PASS: X (reviewers: 1, 3)
|
|
@@ -172,12 +102,7 @@ Add these fields to the consolidated panel report template when using weighted c
|
|
|
172
102
|
- **Overall: PASS/BLOCK** (weighted)
|
|
173
103
|
```
|
|
174
104
|
|
|
175
|
-
### Integration
|
|
176
|
-
|
|
177
|
-
The weighted consensus variant follows the SAME procedure steps (1-6) from the main panel protocol. The only differences are:
|
|
178
|
-
1. Weight assignment happens in step 2 (before spawning reviewers)
|
|
179
|
-
2. Step 4 uses weighted calculation instead of simple count
|
|
180
|
-
3. The consolidated report includes the weighting table
|
|
105
|
+
### Integration
|
|
181
106
|
|
|
182
|
-
|
|
107
|
+
Same steps 1–7 as standard panel. Differences: assign weights in step 2; use weighted calculation in step 4; add weighting table to report. Team Lead decides simple vs. weighted; include rationale in delegation prompt.
|
|
183
108
|
|
|
@@ -3,101 +3,37 @@ name: performance-optimization
|
|
|
3
3
|
description: "Frontend and backend performance optimization patterns including rendering, asset optimization, JavaScript performance, caching, profiling, and code review checklist. Use when optimizing components, reviewing code for performance, or analyzing bundle size and Core Web Vitals."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
<!-- ⚠️ This file is managed by OpenCastle. Edits will be overwritten on update. Customize in the .opencastle/ directory instead. -->
|
|
7
|
-
|
|
8
6
|
# Performance Optimization
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
- **Measure first, optimize second** — profile before optimizing. Use Chrome DevTools, Lighthouse, Datadog.
|
|
13
|
-
- **Optimize for the common case** — focus on frequently executed code paths.
|
|
14
|
-
- **Avoid premature optimization** — write clear code first, optimize when necessary.
|
|
15
|
-
- **Minimize resource usage** — CPU, memory, network, disk.
|
|
16
|
-
- **Prefer simplicity** — simple algorithms are often faster and easier to optimize.
|
|
17
|
-
- **Document performance assumptions** — comment performance-critical code.
|
|
18
|
-
- **Automate performance testing** — integrate into CI/CD.
|
|
19
|
-
- **Set performance budgets** — define limits for load time, memory, API latency.
|
|
20
|
-
|
|
21
|
-
## Rendering and DOM
|
|
22
|
-
|
|
23
|
-
- **Memoization**: Use `React.memo`, `useMemo`, `useCallback` judiciously — only when profiling shows unnecessary re-renders. Don't pre-optimize.
|
|
24
|
-
- Stable `key` props in lists (avoid array indices unless static).
|
|
25
|
-
- Avoid inline styles (can trigger layout thrashing). Prefer CSS classes.
|
|
26
|
-
- CSS transitions/animations over JavaScript for GPU-accelerated effects.
|
|
27
|
-
- `requestIdleCallback` for deferring non-critical rendering.
|
|
28
|
-
|
|
29
|
-
## Asset Optimization
|
|
30
|
-
|
|
31
|
-
- Modern image formats (WebP, AVIF). Tools: ImageOptim, Squoosh.
|
|
32
|
-
- SVGs for icons.
|
|
33
|
-
- Bundle and minify JS/CSS (Webpack, Rollup, esbuild). Tree-shaking.
|
|
34
|
-
- Long-lived cache headers for static assets. Cache busting for updates.
|
|
35
|
-
- `loading="lazy"` for images. Dynamic imports for JS.
|
|
36
|
-
- Font subsetting. `font-display: swap`.
|
|
37
|
-
|
|
38
|
-
## JavaScript Performance
|
|
8
|
+
**Rule:** Measure first (`Chrome DevTools`, `Lighthouse`, `Datadog`), optimize second. Set budgets (load time, memory, API latency). Automate in CI/CD.
|
|
39
9
|
|
|
40
|
-
|
|
41
|
-
- Debounce/throttle scroll, resize, input events.
|
|
42
|
-
- Clean up event listeners, intervals, DOM references (prevent memory leaks).
|
|
43
|
-
- Maps/Sets for lookups. TypedArrays for numeric data.
|
|
44
|
-
- Avoid global variables.
|
|
45
|
-
- Avoid deep object cloning unless necessary.
|
|
10
|
+
## Patterns by Domain
|
|
46
11
|
|
|
47
|
-
|
|
12
|
+
| Domain | Key patterns |
|
|
13
|
+
|--------|-------------|
|
|
14
|
+
| **Rendering** | `React.memo`/`useMemo`/`useCallback` only after profiling; stable `key` props; CSS classes over inline styles; CSS animations (GPU); `requestIdleCallback` for non-critical work |
|
|
15
|
+
| **Assets** | WebP/AVIF images; SVG icons; bundle+minify+tree-shake (esbuild/Rollup); `loading="lazy"`; dynamic imports; long-lived cache headers + cache-busting; font subsetting + `font-display: swap` |
|
|
16
|
+
| **JS** | Web Workers for heavy computation; debounce/throttle events; clean up listeners/intervals; `Map`/`Set` for lookups; `TypedArray` for numeric data |
|
|
17
|
+
| **Node.js** | Async APIs only (never `readFileSync` in prod); clustering/worker threads for CPU; streams for large I/O; profile with `clinic.js` / `node --inspect` |
|
|
48
18
|
|
|
49
|
-
|
|
50
|
-
- Clustering or worker threads for CPU-bound tasks.
|
|
51
|
-
- Streams for large file/network processing.
|
|
52
|
-
- Profile with `clinic.js`, `node --inspect`.
|
|
19
|
+
## Debounce Example
|
|
53
20
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
- [ ] No obvious algorithmic inefficiencies (O(n²) or worse)?
|
|
57
|
-
- [ ] Appropriate data structures?
|
|
58
|
-
- [ ] No unnecessary computations or repeated work?
|
|
59
|
-
- [ ] Caching used where appropriate with correct invalidation?
|
|
60
|
-
- [ ] Database queries optimized, indexed, no N+1?
|
|
61
|
-
- [ ] Large payloads paginated, streamed, or chunked?
|
|
62
|
-
- [ ] No memory leaks or unbounded resource usage?
|
|
63
|
-
- [ ] Network requests minimized, batched, retried on failure?
|
|
64
|
-
- [ ] Assets optimized, compressed, served efficiently?
|
|
65
|
-
- [ ] No blocking operations in hot paths?
|
|
66
|
-
- [ ] Logging in hot paths minimized and structured?
|
|
67
|
-
- [ ] Performance-critical paths documented and tested?
|
|
68
|
-
- [ ] Automated benchmarks for performance-sensitive code?
|
|
69
|
-
- [ ] Alerts for performance regressions?
|
|
70
|
-
- [ ] No anti-patterns (SELECT *, blocking I/O, globals)?
|
|
71
|
-
- [ ] Memoization used judiciously — only where profiling shows benefit?
|
|
72
|
-
|
|
73
|
-
## Practical Examples
|
|
74
|
-
|
|
75
|
-
### Debouncing User Input
|
|
76
|
-
|
|
77
|
-
```javascript
|
|
78
|
-
// BAD: API call on every keystroke
|
|
21
|
+
```js
|
|
22
|
+
// BAD: fetch on every keystroke
|
|
79
23
|
input.addEventListener('input', (e) => fetch(`/search?q=${e.target.value}`));
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
let timeout;
|
|
83
|
-
input.addEventListener('input', (e) => {
|
|
84
|
-
clearTimeout(timeout);
|
|
85
|
-
timeout = setTimeout(() => fetch(`/search?q=${e.target.value}`), 300);
|
|
86
|
-
});
|
|
24
|
+
// GOOD: debounced 300 ms
|
|
25
|
+
let t; input.addEventListener('input', (e) => { clearTimeout(t); t = setTimeout(() => fetch(`/search?q=${e.target.value}`), 300); });
|
|
87
26
|
```
|
|
88
27
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
```html
|
|
92
|
-
<!-- BAD -->
|
|
93
|
-
<img src="large-image.jpg" />
|
|
28
|
+
## Review Checklist
|
|
94
29
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
30
|
+
- [ ] No O(n²)+ algorithms; appropriate data structures
|
|
31
|
+
- [ ] Caching with correct invalidation; no N+1 DB queries
|
|
32
|
+
- [ ] Large payloads paginated/streamed; network requests batched
|
|
33
|
+
- [ ] No memory leaks or blocking ops in hot paths
|
|
34
|
+
- [ ] Assets optimized; memoization only where profiling shows benefit
|
|
35
|
+
- [ ] Benchmarks for perf-sensitive code; alerts for regressions
|
|
98
36
|
|
|
99
37
|
## References
|
|
100
38
|
|
|
101
|
-
- [
|
|
102
|
-
- [MDN: Performance](https://developer.mozilla.org/en-US/docs/Web/Performance)
|
|
103
|
-
- [Lighthouse](https://developers.google.com/web/tools/lighthouse)
|
|
39
|
+
- [web.dev/performance](https://web.dev/performance/) · [MDN Performance](https://developer.mozilla.org/en-US/docs/Web/Performance) · [Lighthouse](https://developers.google.com/web/tools/lighthouse)
|