opencastle 0.10.7 → 0.11.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.
Files changed (103) hide show
  1. package/README.md +4 -0
  2. package/bin/cli.mjs +4 -0
  3. package/dist/cli/dashboard.d.ts.map +1 -1
  4. package/dist/cli/dashboard.js +5 -1
  5. package/dist/cli/dashboard.js.map +1 -1
  6. package/dist/cli/init.test.js +1 -1
  7. package/dist/cli/init.test.js.map +1 -1
  8. package/dist/cli/lesson.d.ts +17 -0
  9. package/dist/cli/lesson.d.ts.map +1 -0
  10. package/dist/cli/lesson.js +294 -0
  11. package/dist/cli/lesson.js.map +1 -0
  12. package/dist/cli/log.d.ts +7 -0
  13. package/dist/cli/log.d.ts.map +1 -0
  14. package/dist/cli/log.js +131 -0
  15. package/dist/cli/log.js.map +1 -0
  16. package/dist/cli/run/executor.js.map +1 -1
  17. package/dist/cli/run/loop-executor.d.ts +3 -0
  18. package/dist/cli/run/loop-executor.d.ts.map +1 -0
  19. package/dist/cli/run/loop-executor.js +154 -0
  20. package/dist/cli/run/loop-executor.js.map +1 -0
  21. package/dist/cli/run/loop-reporter.d.ts +6 -0
  22. package/dist/cli/run/loop-reporter.d.ts.map +1 -0
  23. package/dist/cli/run/loop-reporter.js +112 -0
  24. package/dist/cli/run/loop-reporter.js.map +1 -0
  25. package/dist/cli/run/reporter.d.ts.map +1 -1
  26. package/dist/cli/run/reporter.js +28 -1
  27. package/dist/cli/run/reporter.js.map +1 -1
  28. package/dist/cli/run/schema.d.ts.map +1 -1
  29. package/dist/cli/run/schema.js +104 -52
  30. package/dist/cli/run/schema.js.map +1 -1
  31. package/dist/cli/run/schema.test.js +214 -0
  32. package/dist/cli/run/schema.test.js.map +1 -1
  33. package/dist/cli/run.d.ts.map +1 -1
  34. package/dist/cli/run.js +84 -3
  35. package/dist/cli/run.js.map +1 -1
  36. package/dist/cli/types.d.ts +59 -1
  37. package/dist/cli/types.d.ts.map +1 -1
  38. package/dist/cli/update.d.ts.map +1 -1
  39. package/dist/cli/update.js +54 -1
  40. package/dist/cli/update.js.map +1 -1
  41. package/package.json +1 -1
  42. package/src/cli/dashboard.ts +5 -1
  43. package/src/cli/init.test.ts +1 -1
  44. package/src/cli/lesson.ts +312 -0
  45. package/src/cli/log.ts +133 -0
  46. package/src/cli/run/executor.ts +8 -8
  47. package/src/cli/run/loop-executor.ts +198 -0
  48. package/src/cli/run/loop-reporter.ts +125 -0
  49. package/src/cli/run/reporter.ts +30 -1
  50. package/src/cli/run/schema.test.ts +242 -2
  51. package/src/cli/run/schema.ts +115 -59
  52. package/src/cli/run.ts +82 -5
  53. package/src/cli/types.ts +67 -1
  54. package/src/cli/update.ts +62 -1
  55. package/src/dashboard/dist/index.html +14 -15
  56. package/src/dashboard/node_modules/.vite/deps/_metadata.json +6 -6
  57. package/src/dashboard/scripts/generate-seed-data.ts +23 -43
  58. package/src/dashboard/seed-data/events.ndjson +104 -0
  59. package/src/dashboard/src/pages/index.astro +14 -15
  60. package/src/orchestrator/agents/api-designer.agent.md +1 -1
  61. package/src/orchestrator/agents/architect.agent.md +1 -1
  62. package/src/orchestrator/agents/content-engineer.agent.md +1 -1
  63. package/src/orchestrator/agents/copywriter.agent.md +1 -1
  64. package/src/orchestrator/agents/data-expert.agent.md +1 -1
  65. package/src/orchestrator/agents/database-engineer.agent.md +1 -1
  66. package/src/orchestrator/agents/developer.agent.md +1 -1
  67. package/src/orchestrator/agents/devops-expert.agent.md +1 -1
  68. package/src/orchestrator/agents/documentation-writer.agent.md +1 -1
  69. package/src/orchestrator/agents/performance-expert.agent.md +1 -1
  70. package/src/orchestrator/agents/release-manager.agent.md +1 -1
  71. package/src/orchestrator/agents/security-expert.agent.md +1 -1
  72. package/src/orchestrator/agents/seo-specialist.agent.md +1 -1
  73. package/src/orchestrator/agents/session-guard.agent.md +9 -21
  74. package/src/orchestrator/agents/team-lead.agent.md +8 -34
  75. package/src/orchestrator/agents/testing-expert.agent.md +1 -1
  76. package/src/orchestrator/agents/ui-ux-expert.agent.md +1 -1
  77. package/src/orchestrator/customizations/AGENT-PERFORMANCE.md +11 -12
  78. package/src/orchestrator/customizations/DISPUTES.md +2 -2
  79. package/src/orchestrator/customizations/README.md +1 -3
  80. package/src/orchestrator/customizations/logs/README.md +66 -14
  81. package/src/orchestrator/instructions/ai-optimization.instructions.md +21 -132
  82. package/src/orchestrator/instructions/general.instructions.md +35 -181
  83. package/src/orchestrator/plugins/nx/SKILL.md +1 -1
  84. package/src/orchestrator/prompts/bootstrap-customizations.prompt.md +4 -8
  85. package/src/orchestrator/prompts/bug-fix.prompt.md +4 -4
  86. package/src/orchestrator/prompts/implement-feature.prompt.md +3 -3
  87. package/src/orchestrator/prompts/quick-refinement.prompt.md +3 -3
  88. package/src/orchestrator/prompts/resolve-pr-comments.prompt.md +1 -1
  89. package/src/orchestrator/skills/agent-hooks/SKILL.md +11 -11
  90. package/src/orchestrator/skills/decomposition/SKILL.md +1 -1
  91. package/src/orchestrator/skills/fast-review/SKILL.md +4 -19
  92. package/src/orchestrator/skills/git-workflow/SKILL.md +72 -0
  93. package/src/orchestrator/skills/memory-merger/SKILL.md +1 -1
  94. package/src/orchestrator/skills/observability-logging/SKILL.md +129 -0
  95. package/src/orchestrator/skills/orchestration-protocols/SKILL.md +2 -2
  96. package/src/orchestrator/skills/panel-majority-vote/SKILL.md +4 -7
  97. package/src/orchestrator/skills/self-improvement/SKILL.md +13 -26
  98. package/src/orchestrator/skills/team-lead-reference/SKILL.md +2 -2
  99. package/src/orchestrator/customizations/logs/delegations.ndjson +0 -1
  100. package/src/orchestrator/customizations/logs/panels.ndjson +0 -1
  101. package/src/orchestrator/customizations/logs/reviews.ndjson +0 -0
  102. package/src/orchestrator/customizations/logs/sessions.ndjson +0 -1
  103. /package/src/orchestrator/customizations/logs/{disputes.ndjson → events.ndjson} +0 -0
@@ -50,9 +50,7 @@ Structured machine-readable logs appended automatically by agents during session
50
50
  | File | Purpose |
51
51
  |------|---------|
52
52
  | `README.md` | Schema documentation for the NDJSON log files |
53
- | `sessions.ndjson` | Structured session log entries |
54
- | `delegations.ndjson` | Structured delegation log entries |
55
- | `panels.ndjson` | Structured panel review log entries |
53
+ | `events.ndjson` | All structured event log entries (sessions, delegations, reviews, panels, disputes) |
56
54
 
57
55
  ## When to update
58
56
 
@@ -1,21 +1,64 @@
1
1
  # Agent Session Logs
2
2
 
3
- Append-only NDJSON logs for agent activity tracking. Each file stores one JSON object per line.
3
+ Append-only NDJSON log for agent activity tracking. All events are stored in a single file with a `type` discriminator — one JSON object per line.
4
4
 
5
- ## Files
5
+ ## File
6
6
 
7
- | File | Appended by | Schema |
8
- |------|------------|--------|
9
- | `sessions.ndjson` | All agents (via self-improvement protocol) | Session record |
10
- | `delegations.ndjson` | Team Lead agent | Delegation record |
11
- | `reviews.ndjson` | Team Lead (via fast-review skill) | Fast review record |
12
- | `panels.ndjson` | Panel runner (via panel majority vote skill) | Panel record |
13
- | `disputes.ndjson` | Team Lead (via dispute protocol) | Dispute record |
7
+ | File | Description |
8
+ |------|-------------|
9
+ | `events.ndjson` | All agent events, sorted by timestamp |
14
10
 
15
- ## Session Record Schema
11
+ ## Type Discriminator
12
+
13
+ Each record includes a `type` field that identifies the event kind:
14
+
15
+ | `type` value | Appended by | Description |
16
+ |-------------|-------------|-------------|
17
+ | `session` | All agents (via self-improvement protocol) | Session record |
18
+ | `delegation` | Team Lead agent | Delegation record |
19
+ | `review` | Team Lead (via fast-review skill) | Fast review record |
20
+ | `panel` | Panel runner (via panel majority vote skill) | Panel record |
21
+ | `dispute` | Team Lead (via dispute protocol) | Dispute record |
22
+
23
+ ## CLI Usage
24
+
25
+ Use `opencastle log` to append events. Agents should call this instead of raw `echo` commands.
26
+
27
+ ```sh
28
+ # Session
29
+ opencastle log --type session --agent Developer --model claude-sonnet-4-6 \
30
+ --task "PRJ-57: Fix header component" --outcome success --duration_min 12 \
31
+ --files_changed 5 --retries 0
32
+
33
+ # Delegation
34
+ opencastle log --type delegation --session_id feat/prj-57 --agent Developer \
35
+ --model claude-opus-4-6 --tier fast --mechanism sub-agent \
36
+ --outcome success --phase 2 --file_partition "src/components/,src/pages/"
37
+
38
+ # Review
39
+ opencastle log --type review --tracker_issue PRJ-42 --agent Developer \
40
+ --reviewer_model gpt-5-mini --verdict pass --attempt 1 \
41
+ --issues_critical 0 --issues_major 0 --issues_minor 2 \
42
+ --confidence high --escalated false
43
+
44
+ # Panel
45
+ opencastle log --type panel --panel_key auth-review --verdict pass \
46
+ --pass_count 3 --block_count 0 --must_fix 0 --should_fix 5 \
47
+ --reviewer_model claude-opus-4-6 --weighted false --attempt 1
48
+
49
+ # Dispute
50
+ opencastle log --type dispute --dispute_id DSP-001 --tracker_issue PRJ-42 \
51
+ --priority high --trigger panel-3x-block --implementing_agent Developer \
52
+ --reviewing_agents "Reviewer,Panel (3x)" --total_attempts 6 --status pending
53
+ ```
54
+
55
+ Run `opencastle log --help` for full options.
56
+
57
+ ## Session Record (`type: "session"`)
16
58
 
17
59
  ```json
18
60
  {
61
+ "type": "session",
19
62
  "timestamp": "2026-02-25T14:30:00Z",
20
63
  "agent": "Developer",
21
64
  "model": "gpt-5.3-codex",
@@ -32,6 +75,7 @@ Append-only NDJSON logs for agent activity tracking. Each file stores one JSON o
32
75
 
33
76
  | Field | Type | Required | Description |
34
77
  |-------|------|----------|-------------|
78
+ | `type` | `string` | Yes | Always `"session"` |
35
79
  | `timestamp` | `string` | Yes | ISO 8601 datetime (YYYY-MM-DDTHH:MM:SSZ) |
36
80
  | `agent` | `string` | Yes | Agent name from the registry |
37
81
  | `model` | `string` | Yes | Model used (e.g., `claude-opus-4-6`, `gpt-5.3-codex`) |
@@ -44,10 +88,11 @@ Append-only NDJSON logs for agent activity tracking. Each file stores one JSON o
44
88
  | `lessons_added` | `string[]` | No | Lesson IDs added (e.g., `["LES-015"]`) |
45
89
  | `discoveries` | `string[]` | No | Issues discovered (issue IDs or KNOWN-ISSUES IDs) |
46
90
 
47
- ## Delegation Record Schema
91
+ ## Delegation Record (`type: "delegation"`)
48
92
 
49
93
  ```json
50
94
  {
95
+ "type": "delegation",
51
96
  "timestamp": "2026-02-25T14:30:00Z",
52
97
  "session_id": "feat/prj-57",
53
98
  "agent": "Developer",
@@ -64,6 +109,7 @@ Append-only NDJSON logs for agent activity tracking. Each file stores one JSON o
64
109
 
65
110
  | Field | Type | Required | Description |
66
111
  |-------|------|----------|-------------|
112
+ | `type` | `string` | Yes | Always `"delegation"` |
67
113
  | `timestamp` | `string` | Yes | ISO 8601 datetime (YYYY-MM-DDTHH:MM:SSZ) |
68
114
  | `session_id` | `string` | Yes | Branch name or feature identifier |
69
115
  | `agent` | `string` | Yes | Agent name delegated to |
@@ -76,10 +122,11 @@ Append-only NDJSON logs for agent activity tracking. Each file stores one JSON o
76
122
  | `phase` | `number` | No | Execution phase number |
77
123
  | `file_partition` | `string[]` | No | Directories/files assigned |
78
124
 
79
- ## Fast Review Record Schema
125
+ ## Fast Review Record (`type: "review"`)
80
126
 
81
127
  ```json
82
128
  {
129
+ "type": "review",
83
130
  "timestamp": "2026-02-28T14:30:00Z",
84
131
  "tracker_issue": "PRJ-42",
85
132
  "agent": "Developer",
@@ -97,6 +144,7 @@ Append-only NDJSON logs for agent activity tracking. Each file stores one JSON o
97
144
 
98
145
  | Field | Type | Required | Description |
99
146
  |-------|------|----------|-------------|
147
+ | `type` | `string` | Yes | Always `"review"` |
100
148
  | `timestamp` | `string` | Yes | ISO 8601 datetime (YYYY-MM-DDTHH:MM:SSZ) |
101
149
  | `tracker_issue` | `string` | No | Issue ID if applicable |
102
150
  | `agent` | `string` | Yes | Agent whose output was reviewed |
@@ -110,10 +158,11 @@ Append-only NDJSON logs for agent activity tracking. Each file stores one JSON o
110
158
  | `escalated` | `boolean` | Yes | Whether this review triggered escalation to panel |
111
159
  | `duration_sec` | `number` | No | Review duration in seconds |
112
160
 
113
- ## Panel Record Schema
161
+ ## Panel Record (`type: "panel"`)
114
162
 
115
163
  ```json
116
164
  {
165
+ "type": "panel",
117
166
  "timestamp": "2026-02-25T14:30:00Z",
118
167
  "panel_key": "instruction-refactoring",
119
168
  "verdict": "pass",
@@ -132,6 +181,7 @@ Append-only NDJSON logs for agent activity tracking. Each file stores one JSON o
132
181
 
133
182
  | Field | Type | Required | Description |
134
183
  |-------|------|----------|-------------|
184
+ | `type` | `string` | Yes | Always `"panel"` |
135
185
  | `timestamp` | `string` | Yes | ISO 8601 datetime (YYYY-MM-DDTHH:MM:SSZ) |
136
186
  | `panel_key` | `string` | Yes | Filesystem-safe panel identifier |
137
187
  | `verdict` | `string` | Yes | `pass` or `block` |
@@ -146,10 +196,11 @@ Append-only NDJSON logs for agent activity tracking. Each file stores one JSON o
146
196
  | `artifacts_count` | `number` | No | Number of artifacts reviewed |
147
197
  | `report_path` | `string` | No | Path to the full panel report |
148
198
 
149
- ## Dispute Record Schema
199
+ ## Dispute Record (`type: "dispute"`)
150
200
 
151
201
  ```json
152
202
  {
203
+ "type": "dispute",
153
204
  "timestamp": "2026-02-28T16:00:00Z",
154
205
  "dispute_id": "DSP-001",
155
206
  "tracker_issue": "PRJ-42",
@@ -167,6 +218,7 @@ Append-only NDJSON logs for agent activity tracking. Each file stores one JSON o
167
218
 
168
219
  | Field | Type | Required | Description |
169
220
  |-------|------|----------|-------------|
221
+ | `type` | `string` | Yes | Always `"dispute"` |
170
222
  | `timestamp` | `string` | Yes | ISO 8601 datetime when dispute was created |
171
223
  | `dispute_id` | `string` | Yes | Dispute ID (e.g., `DSP-001`) |
172
224
  | `tracker_issue` | `string` | No | Issue ID if applicable |
@@ -1,145 +1,34 @@
1
1
  ---
2
- description: 'AI assistant optimization techniques for efficient context usage and faster responses'
2
+ description: 'AI assistant optimization patterns for efficient context usage and tool calls'
3
3
  applyTo: '**'
4
4
  ---
5
5
 
6
6
  <!-- ⚠️ This file is managed by OpenCastle. Edits will be overwritten on update. Customize in the .github/customizations/ directory instead. -->
7
7
 
8
- # AI Assistant Optimization Instructions
8
+ # AI Optimization
9
9
 
10
- ## Batch Processing
10
+ Batch independent operations, gather context before acting, and avoid redundant tool calls.
11
11
 
12
- ### DO: Batch Independent Operations
12
+ ## Key Rules
13
13
 
14
- When gathering context, batch all read operations together in a single parallel call:
14
+ - **Batch independent reads** — parallelize file reads, searches, and error checks in a single call instead of sequentially
15
+ - **Don't batch dependent ops** — if step B needs step A's output, run them sequentially
16
+ - **Gather context first** — read and search before editing; don't act on assumptions
17
+ - **Read strategically** — prefer large ranges (500–2000 lines) over many micro-reads; use `grep_search` to locate, then read targeted ranges
18
+ - **Combine searches** — use regex alternation (`word1|word2|word3`) instead of separate searches
19
+ - **Don't re-read** — if a file or sub-agent result is already in context, use it directly
20
+ - **Verify once per phase** — run tests/lint/errors after a batch of edits, not after each individual change
21
+ - **Scale planning to complexity** — trivial (1–2 files) → act directly; large (10+ files) → full decomposition
22
+ - **Trust sub-agent results** — don't re-search or re-read what a sub-agent already returned
23
+ - **Include file paths in delegation prompts** — saves the sub-agent from wasting context on discovery
15
24
 
16
- ```
17
- Good: Read 3 files + search in parallel → 1 cache-friendly turn
18
- Bad: Read file 1 → Read file 2 → Read file 3 → 3 separate turns
19
- ```
25
+ ## Anti-Patterns
20
26
 
21
- When modifying multiple independent files, batch the edits:
22
-
23
- ```
24
- Good: Update 5 config files in parallel
25
- Bad: Update config 1 wait Update config 2 → wait...
26
- ```
27
-
28
- ### DON'T: Batch Dependent Operations
29
-
30
- Don't batch operations where one depends on the output of another:
31
-
32
- ```
33
- Bad: Read file + Edit file (need to read first)
34
- Good: Read file → Analyze → Edit file
35
- ```
36
-
37
- ## Context Gathering Workflow
38
-
39
- Gather all necessary context upfront before analysis/implementation:
40
-
41
- ```
42
- Phase 1 (parallel): Read files + search for patterns + check errors
43
- Phase 2: Analyze and plan
44
- Phase 3 (parallel if independent): Create/modify files
45
- Phase 4: Verify (tests, errors, lint)
46
- ```
47
-
48
- ## Token Reduction Techniques
49
-
50
- ### Strategic Tool Selection
51
-
52
- - Use `grep_search` with `includePattern` to scope searches to specific directories
53
- - Use `file_search` to find files by pattern before reading
54
- - Use `semantic_search` for exploring unfamiliar code instead of multiple grep searches
55
- - Read targeted line ranges when you know approximately where code is
56
-
57
- ### Avoid Redundant Operations
58
-
59
- - Don't re-read files already in context from the same conversation turn
60
- - Check errors once per phase, not after every single change
61
- - Don't search for what's already mentioned in context
62
- - Use regex with alternation (e.g., `word1|word2|word3`) to combine searches
63
-
64
- ### Read Strategically
65
-
66
- - Read larger sections (500-2000 lines) instead of many small reads
67
- - Use `grep_search` to locate code, then read targeted ranges around it
68
- - Deduplicate file paths before batching read operations
69
-
70
- ## Multi-Agent Optimization
71
-
72
- ### Sub-Agent Context Isolation
73
-
74
- Sub-agents run in isolated context windows. Use this to your advantage:
75
-
76
- - **Offload exploration** — fire a sub-agent to research a broad question; only the concise result comes back, keeping your primary context clean
77
- - **Parallel research** — launch multiple sub-agents simultaneously for independent research tasks (e.g., "find all CMS queries" + "list all components using X" at the same time)
78
- - **Detailed prompts save tokens** — a specific sub-agent prompt avoids the sub-agent doing its own exploratory searches, which would waste its context budget
79
-
80
- ### Trust Sub-Agent Results
81
-
82
- - Don't re-read files a sub-agent just analyzed — trust the returned summary
83
- - Don't re-search for patterns a sub-agent already identified
84
- - If a sub-agent returns file paths or code snippets, use them directly
85
-
86
- ### Background Agents for Long Work
87
-
88
- - Delegate tasks expected to take >5 minutes to background agents — they run in parallel without blocking
89
- - Include **all necessary context** in the delegation prompt (background agents can't ask follow-up questions)
90
- - Batch independent background delegations together (e.g., launch DB migration + UI components + docs simultaneously)
91
-
92
- ### Delegation Prompt Efficiency
93
-
94
- - Include exact file paths so the delegated agent doesn't waste time searching
95
- - Reference existing patterns ("follow the structure in `libs/ui-kit/src/lib/Button/`") instead of describing patterns from scratch
96
- - Set clear scope boundaries ("only modify files under `libs/queries/`") to prevent unnecessary exploration
97
-
98
- ## Response Optimization
99
-
100
- - Provide brief progress updates after batched operations
101
- - Describe changes concisely instead of repeating large code blocks
102
- - Plan what context is needed before making tool calls
103
- - Combine multiple related edits in planning before executing
104
-
105
- ## Planning Thresholds
106
-
107
- Scale planning effort to task complexity — don't over-plan simple work:
108
-
109
- | Complexity | Planning | Approach |
110
- |-----------|----------|----------|
111
- | Trivial (1-2 files, clear fix) | None | Act directly |
112
- | Small (3-5 files, single concern) | Mental plan | Brief reasoning, then act |
113
- | Medium (5-10 files, multiple concerns) | Todo list | Track steps, batch reads |
114
- | Large (10+ files, cross-cutting) | Full decomposition | Dependency graph, phased execution |
115
-
116
- **Stop-and-re-plan trigger:** See the Task Decomposition Protocol in `general.instructions.md` (step 5).
117
-
118
- ## Test & Build Output Efficiency
119
-
120
- - Capture full test/build output **once** per verification phase, not after each micro-change
121
- - Pipe verbose output through `tail -n 30` or `grep -E 'FAIL|ERROR|PASS'` to reduce noise
122
- - When tests fail, read the **relevant failure block** — don't re-run the entire suite repeatedly
123
-
124
- ## README Cascade Reading
125
-
126
- When entering an unfamiliar directory, check for a `README.md` before exploring files. READMEs provide architecture context that prevents wasted searches. Priority order:
127
- 1. Project root `README.md` (already covered by instruction files)
128
- 2. Library/app-level `README.md` (e.g., `libs/queries/README.md`)
129
- 3. Feature-level `README.md` (e.g., `libs/data-pipeline/src/lib/scrapers/README.md`)
130
-
131
- ## Anti-Patterns to Avoid
132
-
133
- 1. **Micro-reads** — Reading tiny file sections repeatedly
134
- 2. **Sequential searches** — Running searches one at a time when they're independent
135
- 3. **Premature actions** — Acting before gathering sufficient context
136
- 4. **Silent processing** — Batching without progress updates
137
- 5. **Exploratory tool calls** — Making tool calls without a clear plan
138
- 6. **Over-checking** — Validating after every tiny change instead of batching
139
- 7. **Re-gathering delegated context** — Re-reading files or re-searching after a sub-agent already returned the information
140
- 8. **Vague delegation prompts** — Forcing sub-agents to waste their context budget on discovery you already completed
141
- 9. **Sequential delegation** — Running independent sub-agents one-by-one when they could run in parallel
142
- 10. **Leaking secrets** — Printing tokens, keys, or passwords in terminal output or logs (violates Constitution #1)
143
- 11. **Over-planning** — Writing a full decomposition for a 2-file fix (see Planning Thresholds)
27
+ 1. **Micro-reads** reading tiny file sections repeatedly
28
+ 2. **Sequential searches** — running independent searches one at a time
29
+ 3. **Premature actions** — editing before gathering sufficient context
30
+ 4. **Over-checking** validating after every tiny change instead of batching
31
+ 5. **Re-gathering delegated context** re-reading files a sub-agent already analyzed
32
+ 6. **Over-planning** — full decomposition for a 2-file fix
144
33
 
145
34
  <!-- End of AI Optimization Instructions -->
@@ -13,7 +13,7 @@ applyTo: '**'
13
13
  3. **Leave code better than you found it** — fix adjacent issues when the cost is low.
14
14
  4. **Fail visibly** — surface errors clearly; never swallow exceptions silently.
15
15
  5. **Verify, don't trust** — confirm outcomes with tools (tests, lint, build) rather than assuming success.
16
- 6. **Log every session** — append observability records to `.github/customizations/logs/` before yielding to the user. No exceptions. See § Observability Logging below.
16
+ 6. **Log every session** — append observability records to `.github/customizations/logs/` before yielding to the user. No exceptions. Load the **observability-logging** skill for details.
17
17
 
18
18
  ## Instruction Priority Hierarchy
19
19
 
@@ -66,40 +66,6 @@ Before starting multi-step work, decompose it into individually verifiable tasks
66
66
  - **Browser testing mandatory** for any UI change — verified at responsive breakpoints defined in `testing-config.md`
67
67
  - Load the **testing-workflow** skill for test patterns and the **browser-testing** skill for E2E automation
68
68
 
69
- ## Git Workflow
70
-
71
- **NEVER commit or push directly to the `main` branch.** All changes must go through a feature/fix branch and a pull request.
72
-
73
- 1. **Create a branch** from `main` before making any changes: `git checkout -b <type>/<ticket-id>-<short-description>` (e.g., `fix/tas-21-places-redirect-loop`, `feat/tas-15-new-filter`)
74
- 2. **Commit to the branch** — never to `main`. Reference the task tracker issue ID in every commit message (e.g., `TAS-42: Fix token refresh logic`)
75
- 3. **Push the branch** and open a pull request on GitHub. **Do NOT merge** — PRs are opened for review only
76
- 4. **Link the PR to the task tracker** — Update the issue description with the PR URL so progress is traceable
77
- 5. **Merge via PR** — the only way code reaches `main`, and only after review/approval
78
-
79
- Branch naming convention: `<type>/<ticket-id>-<short-description>` where type is `fix`, `feat`, `chore`, `refactor`, `perf`, or `docs`.
80
-
81
- **This rule has NO exceptions.** Not for "small fixes", not for "just config changes", not for urgent hotfixes. Every change goes through a PR.
82
-
83
- ### PR Safety Rules
84
-
85
- - **Never** use `git push --force` or `git commit --amend` on shared branches
86
- - **Never** expose secrets in commits, PR descriptions, or terminal output (per Constitution #1)
87
- - Use `git push --force-with-lease` only when explicitly asked and on personal branches
88
- - If a secret is accidentally committed, immediately rotate it — git history is permanent
89
-
90
- ### Delivery Outcome (Required for Every Task)
91
-
92
- Every task that produces code changes — whether a roadmap feature, bug fix, follow-up, data pipeline, or refactor — must deliver:
93
-
94
- 1. **Dedicated branch** — `<type>/<ticket-id>-<short-description>` created from `main`
95
- 2. **Atomic commits** — Each commit references the issue ID (e.g., `TAS-42: Add filter component`)
96
- 3. **Pushed branch** — Branch pushed to origin
97
- 4. **Open PR** — Use `gh` CLI to create the PR. **Do NOT merge** — PRs are opened for review only:
98
- ```bash
99
- GH_PAGER=cat gh pr create --base main --title "TAS-XX: Short description" --body "Resolves TAS-XX"
100
- ```
101
- 5. **Task tracker linkage** — The issue is updated with the PR URL, and the PR description references the issue ID
102
-
103
69
  ## Build & Task Commands
104
70
 
105
71
  Use the project's configured task runner for all build, test, lint, and serve commands. **Never invoke test runners or linters directly** — always use the task runner wrapper.
@@ -120,182 +86,70 @@ Follow markdown formatting and documentation standards when writing docs. For te
120
86
 
121
87
  ## AI Optimization
122
88
 
123
- Follow prompt caching and batch processing best practices. See [AI Optimization Guide](ai-optimization.instructions.md) for details.
124
-
125
- ## Discovered Issues Policy
89
+ See [ai-optimization.instructions.md](ai-optimization.instructions.md) for batch processing, tool efficiency, and anti-patterns.
126
90
 
127
- > **⛔ No issue gets ignored.** Untracked bugs discovered during work are a quality gate failure.
128
-
129
- When you encounter a bug, error, or unexpected behavior that is unrelated to the current task:
130
-
131
- 1. **Check if already tracked:**
132
- - Search `.github/customizations/KNOWN-ISSUES.md` for a matching entry
133
- - If you have task tracker tools available, also search for open bugs (use `search_issues` or `list_issues` with bug label)
134
- 2. **If found tracked** — skip it, continue with your current work
135
- 3. **If NOT tracked** — you must act:
136
- - **Unfixable limitation** (third-party constraint, platform restriction, upstream dependency) → add it to `.github/customizations/KNOWN-ISSUES.md` with: Issue ID, Status, Severity, Evidence, Root Cause, Solution Options
137
- - **Fixable bug** → if you have task tracker tools, create a ticket with label `bug`, appropriate priority, and a clear description of the symptoms, reproduction steps, and affected files. If you do NOT have task tracker tools, add a `**Discovered Issues**` section to your output listing the bug details so the Team Lead can track it.
91
+ ## Project Context
138
92
 
139
- Never assume a pre-existing issue is somebody else's problem. If it's not tracked, track it.
93
+ For project-specific context (apps, libraries, tech stack, ports, URLs), see [project.instructions.md](../customizations/project.instructions.md).
140
94
 
141
- ## Task Tracking
95
+ ## Git Workflow
142
96
 
143
- Feature work is tracked in the **task tracker** (see `tracker-config.md` for project details). The Team Lead agent creates and updates issues via MCP. For conventions, load the **task-management** skill.
97
+ **NEVER commit or push directly to the `main` branch.** All changes go through a feature/fix branch and a pull request. Load the **git-workflow** skill for branch naming, PR rules, and the Delivery Outcome checklist.
144
98
 
145
- ### When Task Tracker MCP Tools Are Unavailable
99
+ ## Discovered Issues Policy
146
100
 
147
- If task tracker MCP tools are not available in the current session, do NOT block on issue creation. Instead:
101
+ > **⛔ No issue gets ignored.** Untracked bugs discovered during work are a quality gate failure.
148
102
 
149
- 1. **Document planned issues** in your output with the title, description, and acceptance criteria you would have used
150
- 2. **Proceed with implementation** — the work is still valuable without a ticket number
151
- 3. **Placeholder value for `tracker_issue`:**
152
- - **No tracker configured** (no `task-management` slot bound in `skill-matrix.json`) → use `"N/A"`
153
- - **Tracker configured but tools unavailable** → use the project prefix + `PENDING` (e.g., `"TAS-PENDING"`)
154
- 4. **Ask the user** to create the issues manually if tracking is critical for the task
155
- 5. After implementation, update commit messages and PR descriptions when issue IDs become available
103
+ When you encounter a bug unrelated to the current task: check if already tracked in `KNOWN-ISSUES.md` or the task tracker. If NOT tracked, track it (known issue entry or bug ticket). Never assume a pre-existing issue is somebody else's problem. See the **git-workflow** skill for the full procedure.
156
104
 
157
- ## Observability Logging (Mandatory)
105
+ ## Observability Logging
158
106
 
159
107
  > **⛔ HARD GATE — This is a blocking requirement, not a suggestion.**
160
108
  > Do NOT respond to the user until you have appended the required log records.
161
109
  > A session without log records is a failed session — regardless of code quality.
162
110
 
163
- **Every agent MUST log every session to the observability NDJSON files.** No exceptions. No threshold. No "too small to log." The dashboard depends on this data.
164
-
165
- ### What to log
166
-
167
- | File | Who appends | When | Example command below |
168
- |------|------------|------|----------------------|
169
- | `sessions.ndjson` | **All agents** | After every session — always | ✅ |
170
- | `delegations.ndjson` | **Team Lead** | After each delegation to a specialist agent | ✅ |
171
- | `reviews.ndjson` | **Team Lead** (via fast-review skill) | After each fast review | ✅ |
172
- | `panels.ndjson` | **Panel runner** (via panel majority vote skill) | After each majority-vote review | ✅ |
173
- | `disputes.ndjson` | **Team Lead** (via dispute protocol) | After each dispute record | ✅ |
174
-
175
- See `.github/customizations/logs/README.md` for the full schema of each record.
176
-
177
- ### How to log
178
-
179
- Append one JSON line per task using `echo '...' >> <file>`. When the Team Lead works directly, use the agent role that best describes the work (e.g., `"agent": "Developer"`, `"agent": "UI-UX Expert"`). If a single conversation involves multiple distinct tasks, log one record per task.
180
-
181
- **Session record** (ALL agents, EVERY session):
182
- ```bash
183
- echo '{"timestamp":"2026-03-01T14:00:00Z","agent":"Developer","model":"claude-opus-4-6","task":"Fix login redirect bug","outcome":"success","duration_min":15,"files_changed":3,"retries":0,"lessons_added":[],"discoveries":[]}' >> .github/customizations/logs/sessions.ndjson
184
- ```
185
-
186
- **Delegation record** (Team Lead only, **immediately after each delegation — not at session end**):
187
- ```bash
188
- echo '{"timestamp":"2026-03-01T14:00:00Z","session_id":"feat/prj-57","agent":"Developer","model":"gemini-3.1-pro","tier":"standard","mechanism":"sub-agent","tracker_issue":"PRJ-57","outcome":"success","retries":0,"phase":2,"file_partition":["src/components/"]}' >> .github/customizations/logs/delegations.ndjson
189
- ```
190
- Verify: `tail -1 .github/customizations/logs/delegations.ndjson`
191
-
192
- > **`model` and `tier` must reflect the delegated agent's assignment from the agent registry** — not the Team Lead's own model.
193
-
194
- **Fast review record** (Team Lead, **immediately after each fast review**):
195
- ```bash
196
- echo '{"timestamp":"2026-03-01T14:30:00Z","tracker_issue":"PRJ-42","agent":"Developer","reviewer_model":"gpt-5-mini","verdict":"pass","attempt":1,"issues_critical":0,"issues_major":0,"issues_minor":2,"confidence":"high","escalated":false,"duration_sec":45}' >> .github/customizations/logs/reviews.ndjson
197
- ```
198
- Verify: `tail -1 .github/customizations/logs/reviews.ndjson`
199
-
200
- **Panel record** (Panel runner, **immediately after each panel majority vote**):
201
- ```bash
202
- echo '{"timestamp":"2026-03-01T15:00:00Z","panel_key":"auth-review","verdict":"pass","pass_count":2,"block_count":1,"must_fix":0,"should_fix":3,"reviewer_model":"claude-opus-4-6","weighted":false,"attempt":1,"tracker_issue":"PRJ-42","artifacts_count":5}' >> .github/customizations/logs/panels.ndjson
203
- ```
204
- Verify: `tail -1 .github/customizations/logs/panels.ndjson`
205
-
206
- **Dispute record** (Team Lead, **immediately after each dispute**):
207
- ```bash
208
- echo '{"timestamp":"2026-03-01T16:00:00Z","dispute_id":"DSP-001","tracker_issue":"PRJ-42","priority":"high","trigger":"panel-3x-block","implementing_agent":"Developer","reviewing_agents":["Reviewer","Panel (3x)"],"total_attempts":6,"est_tokens_spent":120000,"status":"pending","resolution_option_chosen":null,"resolved_at":null}' >> .github/customizations/logs/disputes.ndjson
209
- ```
210
- Verify: `tail -1 .github/customizations/logs/disputes.ndjson`
211
-
212
- ### Pre-Response Logging Checklist
213
-
214
- **STOP before responding to the user.** Verify each applicable item:
215
-
216
- - [ ] **Session logged** — `sessions.ndjson` has a new line for this session (ALWAYS required)
217
- - [ ] **Delegations logged** — `delegations.ndjson` has a line for **each** delegation (Team Lead only). Count delegations → count records → must match
218
- - [ ] **Reviews logged** — `reviews.ndjson` has a line for **each** fast review performed. Count reviews → count records → must match
219
- - [ ] **Panels logged** — `panels.ndjson` has a line for **each** panel review performed. Count panels → count records → must match
220
- - [ ] **Disputes logged** — `disputes.ndjson` has a line for **each** dispute created. Count disputes → count records → must match
221
-
222
- If ANY required log is missing, append it NOW before responding.
223
-
224
- ### Rules
225
-
226
- - **Log before yielding to the user** — logging is the LAST action before responding. This is Constitution rule #6.
227
- - **Log per task**, not per conversation. Multiple tasks = multiple records.
228
- - **Never batch-log retrospectively** across sessions.
229
- - **Verify the append succeeded** — if unsure, `tail -1` the file to confirm.
111
+ **Every agent MUST log every session** to `.github/customizations/logs/events.ndjson`. No exceptions. No threshold. No "too small to log." Load the **observability-logging** skill for CLI commands, record schemas, and the full logging checklist.
230
112
 
231
113
  ## Self-Improvement Protocol
232
114
 
233
115
  > **⛔ HARD GATE — Lessons are the team's collective memory. Skipping them causes repeated failures.**
234
116
 
235
- **Every agent must learn from mistakes and share knowledge.** This prevents the same pitfalls from being repeated across sessions.
236
-
237
117
  1. **Before starting work:** Read `.github/customizations/LESSONS-LEARNED.md` — apply relevant lessons proactively. This is NOT optional.
238
- 2. **During execution:** If any of these triggers occur, **immediately** add a lesson entry to `.github/customizations/LESSONS-LEARNED.md`:
239
- - Retry with different approach that works
240
- - Tool call fails unexpectedly (discover correct parameter format)
241
- - Workaround needed for platform limitation
242
- - Docs are misleading (reality differs from documentation)
243
- - Configuration surprise (default behavior differs from expectation)
244
- - Error message is unhelpful (real cause was something else)
245
- 3. **Update source files:** If the lesson reveals a gap in instruction/skill files, update those files too
246
- 4. **Update instructions:** Proactively suggest updates to `.github/instructions/` or `.github/skills/` files when:
247
- - The user had to intervene or correct the agent's approach
248
- - Multiple back-and-forth attempts were needed to get something right
249
- - A change touched files you wouldn't have guessed from the task description
250
- - Something worked differently than expected (API quirk, tool behavior, config side-effect)
251
- - A recurring pattern should be codified (workaround, convention, tool quirk)
252
-
253
- **When NOT to update:** Don't add obvious patterns, standard practices, or things easily discoverable by reading a few files. Instruction files capture *tribal knowledge* — what isn't obvious from the code.
254
-
255
- For the full protocol, load the **self-improvement** skill.
256
-
257
- ## Project Context
258
-
259
- For project-specific context (apps, libraries, tech stack, ports, URLs), see [project.instructions.md](../customizations/project.instructions.md).
118
+ 2. **During execution:** If you retry with a different approach and it works, use the **self-improvement** skill to add a lesson immediately.
119
+ 3. **Update source files:** If the lesson reveals a gap in instruction/skill files, update those files too.
260
120
 
261
121
  ## Universal Agent Rules
262
122
 
263
123
  These rules apply to ALL specialist agents automatically. **Do not duplicate them in individual agent files.**
264
124
 
265
- 1. **Never delegate** — Specialist agents complete their own work and return results. Never invoke the Team Lead or spawn sub-agents. If work requires another domain, document the need in your output contract.
266
- 2. **Follow the Discovered Issues Policy** — Track any pre-existing bugs found during your work (see § Discovered Issues Policy above).
267
- 3. **Read and update lessons** — Read `.github/customizations/LESSONS-LEARNED.md` before starting. If you retry anything with a different approach that works, add a lesson immediately.
268
- 4. **Log every session** — Append to `.github/customizations/logs/sessions.ndjson` after every session. No exceptions. See § Observability Logging above. This is Constitution rule #6 — a blocking gate, not optional.
269
-
270
- ## Base Output Contract
125
+ 1. **Never delegate** — Specialist agents complete their own work and return results. Never invoke the Team Lead or spawn sub-agents.
126
+ 2. **Follow the Discovered Issues Policy** — Track any pre-existing bugs found during your work (see above).
127
+ 3. **Read and update lessons** — See Self-Improvement Protocol above.
128
+ 4. **Log every session** — See Observability Logging above. This is Constitution rule #6 — a blocking gate, not optional.
271
129
 
272
- Every specialist agent's Output Contract MUST end with these standard items (in addition to domain-specific items above them):
130
+ ## Pre-Response Quality Gate
273
131
 
274
- - **Observability Logged** Confirm ALL applicable log records were appended (Constitution rule #6):
275
- - `sessions.ndjson` — ALWAYS (every agent, every session)
276
- - `delegations.ndjson` — if delegations occurred (Team Lead only)
277
- - `reviews.ndjson` — if fast reviews occurred
278
- - `panels.ndjson` — if panel reviews occurred
279
- - `disputes.ndjson` — if disputes were created
280
- - **Discovered Issues** — Pre-existing bugs or anomalies found during work, with tracking action taken per the Discovered Issues Policy
281
- - **Lessons Applied** — Lessons from `.github/customizations/LESSONS-LEARNED.md` that influenced this work, and any new lessons added
132
+ > **⛔ STOP before responding to the user.** Run through this checklist. If ANY required item is missing, fix it NOW.
282
133
 
283
- Agents reference this contract with: `See **Base Output Contract** in general.instructions.md for the standard closing items.`
134
+ - [ ] **Lessons read** `LESSONS-LEARNED.md` was read at session start
135
+ - [ ] **Lessons captured** — If any retry occurred, a new lesson was added via the **self-improvement** skill
136
+ - [ ] **Discovered issues tracked** — Any pre-existing bugs found were tracked (Discovered Issues Policy)
137
+ - [ ] **Lint/type/test pass** — No new errors introduced; verification ran after code changes (Constitution rule #5)
138
+ - [ ] **Session logged** — `events.ndjson` has a new `session` record (Constitution rule #6 — ALWAYS required)
139
+ - [ ] **Delegations logged** — `events.ndjson` has a `delegation` record for each delegation (Team Lead only)
140
+ - [ ] **Reviews logged** — `events.ndjson` has a `review` record for each fast review (if any)
141
+ - [ ] **Panels logged** — `events.ndjson` has a `panel` record for each panel review (if any)
284
142
 
285
- ## Pre-Response Quality Gate
143
+ Load the **observability-logging** skill for CLI commands, Base Output Contract, and detailed schemas.
286
144
 
287
- > **⛔ STOP before responding to the user.** Run through this checklist. If ANY required item is missing, fix it NOW.
145
+ ## Workflow & Governance Skills
288
146
 
289
- This is the single exit gate for every session. All items are mandatory unless marked conditional.
147
+ These skills provide detailed procedures. Load when their phase is reached.
290
148
 
291
- - [ ] **Lessons read** — `.github/customizations/LESSONS-LEARNED.md` was read at session start (Self-Improvement Protocol)
292
- - [ ] **Lessons captured** — If any retry occurred, a new lesson was added to `LESSONS-LEARNED.md`
293
- - [ ] **Discovered issues tracked** Any pre-existing bugs found were added to `KNOWN-ISSUES.md` or a tracker ticket was created (Discovered Issues Policy)
294
- - [ ] **Lint/type/test pass** No new errors introduced; verification ran after code changes (Constitution rule #5)
295
- - [ ] **Session logged** `sessions.ndjson` has a new line for this session (Constitution rule #6 — ALWAYS required)
296
- - [ ] **Delegations logged** — `delegations.ndjson` has a line for each delegation (Team Lead only)
297
- - [ ] **Reviews logged** — `reviews.ndjson` has a line for each fast review performed (if any)
298
- - [ ] **Panels logged** — `panels.ndjson` has a line for each panel review performed (if any)
299
- - [ ] **Disputes logged** — `disputes.ndjson` has a line for each dispute created (if any)
149
+ | Concern | Skill |
150
+ |---------|-------|
151
+ | Branch naming, PR rules, delivery outcome, task tracking | **git-workflow** |
152
+ | Log CLI commands, record schemas, output contracts | **observability-logging** |
153
+ | Lesson writing CLI, categories, quality standards | **self-improvement** |
300
154
 
301
155
  <!-- End of Coding Standards -->
@@ -154,7 +154,7 @@ Before running any generator, complete these steps:
154
154
  - Read the error message carefully
155
155
  - Common causes: missing required options, invalid values, conflicting files, missing dependencies
156
156
  - Adjust options and retry
157
- - Add a lesson to `.github/customizations/LESSONS-LEARNED.md` if the fix was non-obvious
157
+ - Use the **self-improvement** skill to add a lesson if the fix was non-obvious
158
158
 
159
159
  ### Phase 4: Post-Generation
160
160