codingbuddy-rules 4.4.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ai-rules/adapters/antigravity.md +6 -6
- package/.ai-rules/adapters/claude-code.md +107 -4
- package/.ai-rules/adapters/codex.md +5 -5
- package/.ai-rules/adapters/cursor.md +2 -2
- package/.ai-rules/adapters/kiro.md +8 -8
- package/.ai-rules/adapters/opencode.md +7 -7
- package/.ai-rules/adapters/q.md +2 -2
- package/.ai-rules/agents/README.md +66 -16
- package/.ai-rules/agents/accessibility-specialist.json +2 -1
- package/.ai-rules/agents/act-mode.json +2 -1
- package/.ai-rules/agents/agent-architect.json +8 -7
- package/.ai-rules/agents/ai-ml-engineer.json +1 -0
- package/.ai-rules/agents/architecture-specialist.json +1 -0
- package/.ai-rules/agents/auto-mode.json +4 -2
- package/.ai-rules/agents/backend-developer.json +1 -0
- package/.ai-rules/agents/code-quality-specialist.json +1 -0
- package/.ai-rules/agents/code-reviewer.json +65 -64
- package/.ai-rules/agents/data-engineer.json +8 -7
- package/.ai-rules/agents/data-scientist.json +10 -9
- package/.ai-rules/agents/devops-engineer.json +1 -0
- package/.ai-rules/agents/documentation-specialist.json +1 -0
- package/.ai-rules/agents/eval-mode.json +20 -19
- package/.ai-rules/agents/event-architecture-specialist.json +1 -0
- package/.ai-rules/agents/frontend-developer.json +1 -0
- package/.ai-rules/agents/i18n-specialist.json +2 -1
- package/.ai-rules/agents/integration-specialist.json +1 -0
- package/.ai-rules/agents/migration-specialist.json +1 -0
- package/.ai-rules/agents/mobile-developer.json +8 -7
- package/.ai-rules/agents/observability-specialist.json +1 -0
- package/.ai-rules/agents/parallel-orchestrator.json +346 -0
- package/.ai-rules/agents/performance-specialist.json +1 -0
- package/.ai-rules/agents/plan-mode.json +3 -1
- package/.ai-rules/agents/plan-reviewer.json +208 -0
- package/.ai-rules/agents/platform-engineer.json +1 -0
- package/.ai-rules/agents/security-engineer.json +9 -8
- package/.ai-rules/agents/security-specialist.json +2 -1
- package/.ai-rules/agents/seo-specialist.json +1 -0
- package/.ai-rules/agents/software-engineer.json +1 -0
- package/.ai-rules/agents/solution-architect.json +11 -10
- package/.ai-rules/agents/systems-developer.json +9 -8
- package/.ai-rules/agents/technical-planner.json +11 -10
- package/.ai-rules/agents/test-engineer.json +7 -6
- package/.ai-rules/agents/test-strategy-specialist.json +1 -0
- package/.ai-rules/agents/tooling-engineer.json +4 -3
- package/.ai-rules/agents/ui-ux-designer.json +1 -0
- package/.ai-rules/keyword-modes.json +4 -4
- package/.ai-rules/rules/clarification-guide.md +14 -14
- package/.ai-rules/rules/core.md +90 -1
- package/.ai-rules/rules/parallel-execution.md +217 -0
- package/.ai-rules/skills/README.md +23 -1
- package/.ai-rules/skills/agent-design/SKILL.md +5 -0
- package/.ai-rules/skills/agent-design/examples/agent-template.json +58 -0
- package/.ai-rules/skills/agent-design/references/expertise-guidelines.md +112 -0
- package/.ai-rules/skills/agent-discussion/SKILL.md +199 -0
- package/.ai-rules/skills/agent-discussion-panel/SKILL.md +448 -0
- package/.ai-rules/skills/api-design/SKILL.md +5 -0
- package/.ai-rules/skills/api-design/examples/error-response.json +159 -0
- package/.ai-rules/skills/api-design/examples/openapi-template.yaml +393 -0
- package/.ai-rules/skills/build-fix/SKILL.md +234 -0
- package/.ai-rules/skills/code-explanation/SKILL.md +4 -0
- package/.ai-rules/skills/context-management/SKILL.md +1 -0
- package/.ai-rules/skills/cost-budget/SKILL.md +348 -0
- package/.ai-rules/skills/cross-repo-issues/SKILL.md +257 -0
- package/.ai-rules/skills/database-migration/SKILL.md +1 -0
- package/.ai-rules/skills/deepsearch/SKILL.md +214 -0
- package/.ai-rules/skills/deployment-checklist/SKILL.md +1 -0
- package/.ai-rules/skills/error-analysis/SKILL.md +1 -0
- package/.ai-rules/skills/finishing-a-development-branch/SKILL.md +281 -0
- package/.ai-rules/skills/frontend-design/SKILL.md +5 -0
- package/.ai-rules/skills/frontend-design/examples/component-template.tsx +203 -0
- package/.ai-rules/skills/frontend-design/references/css-patterns.md +243 -0
- package/.ai-rules/skills/git-master/SKILL.md +358 -0
- package/.ai-rules/skills/incident-response/SKILL.md +1 -0
- package/.ai-rules/skills/legacy-modernization/SKILL.md +1 -0
- package/.ai-rules/skills/mcp-builder/SKILL.md +7 -0
- package/.ai-rules/skills/mcp-builder/examples/resource-example.ts +233 -0
- package/.ai-rules/skills/mcp-builder/examples/tool-example.ts +203 -0
- package/.ai-rules/skills/mcp-builder/references/protocol-spec.md +215 -0
- package/.ai-rules/skills/performance-optimization/SKILL.md +3 -0
- package/.ai-rules/skills/plan-and-review/SKILL.md +115 -0
- package/.ai-rules/skills/pr-all-in-one/SKILL.md +15 -13
- package/.ai-rules/skills/pr-all-in-one/configuration-guide.md +7 -7
- package/.ai-rules/skills/pr-all-in-one/pr-templates.md +10 -10
- package/.ai-rules/skills/pr-review/SKILL.md +4 -0
- package/.ai-rules/skills/receiving-code-review/SKILL.md +347 -0
- package/.ai-rules/skills/refactoring/SKILL.md +1 -0
- package/.ai-rules/skills/requesting-code-review/SKILL.md +348 -0
- package/.ai-rules/skills/rule-authoring/SKILL.md +5 -0
- package/.ai-rules/skills/rule-authoring/examples/rule-template.md +142 -0
- package/.ai-rules/skills/rule-authoring/examples/trigger-patterns.md +126 -0
- package/.ai-rules/skills/security-audit/SKILL.md +4 -0
- package/.ai-rules/skills/skill-creator/SKILL.md +461 -0
- package/.ai-rules/skills/skill-creator/agents/analyzer.md +206 -0
- package/.ai-rules/skills/skill-creator/agents/comparator.md +167 -0
- package/.ai-rules/skills/skill-creator/agents/grader.md +152 -0
- package/.ai-rules/skills/skill-creator/assets/eval_review.html +289 -0
- package/.ai-rules/skills/skill-creator/assets/skill-template.md +43 -0
- package/.ai-rules/skills/skill-creator/eval-viewer/generate_review.py +496 -0
- package/.ai-rules/skills/skill-creator/references/frontmatter-guide.md +632 -0
- package/.ai-rules/skills/skill-creator/references/multi-tool-compat.md +480 -0
- package/.ai-rules/skills/skill-creator/references/schemas.md +784 -0
- package/.ai-rules/skills/skill-creator/scripts/aggregate_benchmark.py +302 -0
- package/.ai-rules/skills/skill-creator/scripts/init_skill.sh +196 -0
- package/.ai-rules/skills/skill-creator/scripts/run_loop.py +327 -0
- package/.ai-rules/skills/systematic-debugging/SKILL.md +1 -0
- package/.ai-rules/skills/tech-debt/SKILL.md +1 -0
- package/.ai-rules/skills/test-coverage-gate/SKILL.md +303 -0
- package/.ai-rules/skills/tmux-master/SKILL.md +491 -0
- package/.ai-rules/skills/using-git-worktrees/SKILL.md +368 -0
- package/.ai-rules/skills/verification-before-completion/SKILL.md +234 -0
- package/.ai-rules/skills/widget-slot-architecture/SKILL.md +6 -0
- package/.ai-rules/skills/widget-slot-architecture/examples/parallel-route-setup.tsx +206 -0
- package/.ai-rules/skills/widget-slot-architecture/examples/widget-component.tsx +250 -0
- package/.ai-rules/skills/writing-plans/SKILL.md +78 -0
- package/bin/cli.js +178 -0
- package/lib/init/detect-stack.js +148 -0
- package/lib/init/generate-config.js +31 -0
- package/lib/init/index.js +86 -0
- package/lib/init/prompt.js +60 -0
- package/lib/init/scaffold.js +67 -0
- package/lib/init/suggest-agent.js +46 -0
- package/package.json +10 -2
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cost-budget
|
|
3
|
+
description: >-
|
|
4
|
+
Use when managing AI session costs, setting budget limits, or preventing
|
|
5
|
+
cost overruns in autonomous workflows like taskMaestro, autopilot, ralph
|
|
6
|
+
loops, and parallel agent execution. Defines cost tracking protocol,
|
|
7
|
+
threshold alerts, and auto-pause mechanism.
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Cost Budget Management
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
Autonomous AI workflows can consume unbounded resources without guardrails. A single runaway loop — autopilot, ralph, or a multi-wave taskMaestro session — can burn through API credits before anyone notices.
|
|
15
|
+
|
|
16
|
+
**Core principle:** Every autonomous workflow must have a cost ceiling. No budget means unlimited spend.
|
|
17
|
+
|
|
18
|
+
**Iron Law:**
|
|
19
|
+
```
|
|
20
|
+
NO AUTONOMOUS EXECUTION WITHOUT A DECLARED BUDGET
|
|
21
|
+
If no budget is set, warn before starting. If budget is exceeded, pause and require override.
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## When to Use
|
|
25
|
+
|
|
26
|
+
- Starting any autonomous workflow (autopilot, ralph, ultrawork, taskMaestro)
|
|
27
|
+
- Running parallel agents across multiple panes or worktrees
|
|
28
|
+
- Multi-session tasks expected to exceed a few dollars
|
|
29
|
+
- Any workflow where cost visibility matters to the user
|
|
30
|
+
- Setting up per-project or per-team cost guardrails
|
|
31
|
+
|
|
32
|
+
## When NOT to Use
|
|
33
|
+
|
|
34
|
+
- Single interactive conversations (cost is negligible)
|
|
35
|
+
- Quick one-off questions or file reads
|
|
36
|
+
- Workflows where the user explicitly opts out of budget tracking
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Cost Tracking Protocol
|
|
41
|
+
|
|
42
|
+
### Data Collection Points
|
|
43
|
+
|
|
44
|
+
Cost data is collected at three levels:
|
|
45
|
+
|
|
46
|
+
| Level | Scope | Data Source | Granularity |
|
|
47
|
+
|-------|-------|-------------|-------------|
|
|
48
|
+
| **Session** | Single Claude Code session | Token usage from API responses | Per-request |
|
|
49
|
+
| **Wave** | One taskMaestro wave (N parallel panes) | Aggregated session costs per pane | Per-wave |
|
|
50
|
+
| **Project** | All sessions in a project directory | Cumulative across sessions | Running total |
|
|
51
|
+
|
|
52
|
+
### Cost Estimation
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
Cost = (input_tokens × input_price) + (output_tokens × output_price)
|
|
56
|
+
|
|
57
|
+
Model pricing (per 1M tokens):
|
|
58
|
+
opus: input=$15.00 output=$75.00
|
|
59
|
+
sonnet: input=$3.00 output=$15.00
|
|
60
|
+
haiku: input=$0.25 output=$1.25
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Note:** Prices are approximate and should be updated when model pricing changes. The skill defines the protocol, not hardcoded prices.
|
|
64
|
+
|
|
65
|
+
### Collection Methods
|
|
66
|
+
|
|
67
|
+
1. **Environment variables** (preferred):
|
|
68
|
+
```bash
|
|
69
|
+
export COST_BUDGET_USD=10.00 # Total budget in USD
|
|
70
|
+
export COST_BUDGET_TOKENS=5000000 # Alternative: token-based budget
|
|
71
|
+
export COST_BUDGET_SCOPE=project # session | wave | project
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
2. **Configuration file** (`codingbuddy.config.json`):
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"costBudget": {
|
|
78
|
+
"limit": 10.00,
|
|
79
|
+
"currency": "USD",
|
|
80
|
+
"scope": "project",
|
|
81
|
+
"thresholds": {
|
|
82
|
+
"info": 0.50,
|
|
83
|
+
"warn": 0.80,
|
|
84
|
+
"critical": 1.00
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
3. **MCP state** (runtime tracking):
|
|
91
|
+
```
|
|
92
|
+
state_write(mode: "cost-budget", state: {
|
|
93
|
+
"spent": "4.52",
|
|
94
|
+
"budget": "10.00",
|
|
95
|
+
"tokens_used": "2340000"
|
|
96
|
+
})
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Token Counting
|
|
100
|
+
|
|
101
|
+
Track tokens per request and accumulate:
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
Per request:
|
|
105
|
+
input_tokens → from API response headers or usage field
|
|
106
|
+
output_tokens → from API response headers or usage field
|
|
107
|
+
cost_usd → calculated from model pricing
|
|
108
|
+
|
|
109
|
+
Accumulated:
|
|
110
|
+
session_total = sum(all request costs in session)
|
|
111
|
+
wave_total = sum(all session costs in wave)
|
|
112
|
+
project_total = sum(all wave/session costs in project)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Budget Configuration
|
|
118
|
+
|
|
119
|
+
### Threshold Levels
|
|
120
|
+
|
|
121
|
+
Three threshold levels trigger different actions:
|
|
122
|
+
|
|
123
|
+
| Level | Default | Trigger | Action |
|
|
124
|
+
|-------|---------|---------|--------|
|
|
125
|
+
| **INFO** | 50% of budget | Informational milestone | Log to terminal, continue |
|
|
126
|
+
| **WARN** | 80% of budget | Approaching limit | Terminal alert + optional webhook, continue |
|
|
127
|
+
| **CRITICAL** | 100% of budget | Budget exhausted | Terminal alert + webhook + **auto-pause** |
|
|
128
|
+
|
|
129
|
+
### Budget Scopes
|
|
130
|
+
|
|
131
|
+
| Scope | Description | Use Case |
|
|
132
|
+
|-------|-------------|----------|
|
|
133
|
+
| `session` | Single CLI session | Quick tasks, one-off work |
|
|
134
|
+
| `wave` | One taskMaestro wave | Per-wave cost control in parallel execution |
|
|
135
|
+
| `project` | Cumulative across all sessions | Long-running projects with total budget |
|
|
136
|
+
|
|
137
|
+
### Budget Override
|
|
138
|
+
|
|
139
|
+
When the CRITICAL threshold is reached, the workflow pauses. To continue:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# Explicit override for current session
|
|
143
|
+
export COST_BUDGET_OVERRIDE=true
|
|
144
|
+
|
|
145
|
+
# Or increase the budget
|
|
146
|
+
export COST_BUDGET_USD=20.00
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**Override rules:**
|
|
150
|
+
- Override must be explicit — never auto-continue past 100%
|
|
151
|
+
- Override resets the threshold to the new budget
|
|
152
|
+
- Log every override event for audit trail
|
|
153
|
+
- Override does not disable future threshold checks
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Alert Channels
|
|
158
|
+
|
|
159
|
+
### Terminal Notification (Default)
|
|
160
|
+
|
|
161
|
+
Always active. Alerts appear inline in the terminal:
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
┌─────────────────────────────────────────────┐
|
|
165
|
+
│ 💰 COST ALERT [INFO] │
|
|
166
|
+
│ Budget: $5.00 / $10.00 (50%) │
|
|
167
|
+
│ Tokens: 1.2M used │
|
|
168
|
+
│ Status: Continuing │
|
|
169
|
+
└─────────────────────────────────────────────┘
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
┌─────────────────────────────────────────────┐
|
|
174
|
+
│ ⚠️ COST ALERT [WARN] │
|
|
175
|
+
│ Budget: $8.00 / $10.00 (80%) │
|
|
176
|
+
│ Tokens: 3.8M used │
|
|
177
|
+
│ Status: Approaching limit — review spend │
|
|
178
|
+
└─────────────────────────────────────────────┘
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
┌─────────────────────────────────────────────┐
|
|
183
|
+
│ 🛑 COST ALERT [CRITICAL] │
|
|
184
|
+
│ Budget: $10.00 / $10.00 (100%) │
|
|
185
|
+
│ Tokens: 5.0M used │
|
|
186
|
+
│ Status: PAUSED — override required │
|
|
187
|
+
│ │
|
|
188
|
+
│ To continue: │
|
|
189
|
+
│ export COST_BUDGET_OVERRIDE=true │
|
|
190
|
+
│ # or increase: export COST_BUDGET_USD=20 │
|
|
191
|
+
└─────────────────────────────────────────────┘
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Webhook (Optional)
|
|
195
|
+
|
|
196
|
+
For remote notifications (Slack, Discord, PagerDuty, custom endpoints):
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
export COST_ALERT_WEBHOOK_URL=https://hooks.slack.com/services/...
|
|
200
|
+
export COST_ALERT_WEBHOOK_EVENTS=warn,critical # which levels trigger webhook
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**Webhook payload:**
|
|
204
|
+
```json
|
|
205
|
+
{
|
|
206
|
+
"event": "cost_alert",
|
|
207
|
+
"level": "warn",
|
|
208
|
+
"budget_usd": 10.00,
|
|
209
|
+
"spent_usd": 8.00,
|
|
210
|
+
"percent": 80,
|
|
211
|
+
"tokens_used": 3800000,
|
|
212
|
+
"scope": "project",
|
|
213
|
+
"project": "codingbuddy",
|
|
214
|
+
"session_id": "abc-123",
|
|
215
|
+
"timestamp": "2026-03-22T14:00:00Z"
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
**Webhook rules:**
|
|
220
|
+
- Webhook failures must not block the workflow
|
|
221
|
+
- Retry once on failure, then log and continue
|
|
222
|
+
- Include project name and session ID for traceability
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## Auto-Pause Mechanism
|
|
227
|
+
|
|
228
|
+
### Pause Behavior
|
|
229
|
+
|
|
230
|
+
When the CRITICAL threshold (100%) is reached:
|
|
231
|
+
|
|
232
|
+
1. **Stop** — Halt the current autonomous loop iteration
|
|
233
|
+
2. **Alert** — Display terminal notification + fire webhook
|
|
234
|
+
3. **Save state** — Persist current progress to context document
|
|
235
|
+
4. **Wait** — Do not proceed until explicit override or budget increase
|
|
236
|
+
5. **Log** — Record the pause event with timestamp and spend data
|
|
237
|
+
|
|
238
|
+
### Pause Points by Workflow
|
|
239
|
+
|
|
240
|
+
| Workflow | Pause Point | What Happens |
|
|
241
|
+
|----------|-------------|--------------|
|
|
242
|
+
| **autopilot** | Between iterations | Current iteration completes, next blocked |
|
|
243
|
+
| **ralph** | Between architect reviews | Current cycle completes, next blocked |
|
|
244
|
+
| **ultrawork** | Between task assignments | Current task completes, next blocked |
|
|
245
|
+
| **taskMaestro** | Between waves | Current wave completes, next wave blocked |
|
|
246
|
+
| **parallel agents** | At agent completion | Running agents finish, no new agents spawn |
|
|
247
|
+
|
|
248
|
+
**Key:** Never interrupt mid-operation. Always complete the current atomic unit, then pause.
|
|
249
|
+
|
|
250
|
+
### Override Protocol
|
|
251
|
+
|
|
252
|
+
```
|
|
253
|
+
1. User sees CRITICAL alert
|
|
254
|
+
2. User reviews spend breakdown
|
|
255
|
+
3. User decides:
|
|
256
|
+
a. Stop entirely → no action needed, workflow stays paused
|
|
257
|
+
b. Continue with new budget → export COST_BUDGET_USD=<new_amount>
|
|
258
|
+
c. Continue without limit → export COST_BUDGET_OVERRIDE=true
|
|
259
|
+
4. Workflow resumes from saved state
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## TaskMaestro Integration
|
|
265
|
+
|
|
266
|
+
### Per-Wave Budget Allocation
|
|
267
|
+
|
|
268
|
+
When running taskMaestro with a project budget, allocate per-wave:
|
|
269
|
+
|
|
270
|
+
```
|
|
271
|
+
Total budget: $20.00
|
|
272
|
+
Estimated waves: 4
|
|
273
|
+
Per-wave allocation: $5.00 per wave
|
|
274
|
+
|
|
275
|
+
Wave 1: $5.00 budget → actual: $3.20 → remaining pool: $16.80
|
|
276
|
+
Wave 2: $5.60 budget (redistributed) → actual: $4.10 → remaining pool: $12.70
|
|
277
|
+
Wave 3: $6.35 budget (redistributed) → ...
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
**Redistribution rule:** Unspent budget from completed waves rolls into remaining waves equally.
|
|
281
|
+
|
|
282
|
+
### Cross-Pane Aggregation
|
|
283
|
+
|
|
284
|
+
Each tmux pane in a taskMaestro wave runs an independent session. Aggregation:
|
|
285
|
+
|
|
286
|
+
```
|
|
287
|
+
Wave cost = sum(pane_1_cost + pane_2_cost + ... + pane_N_cost)
|
|
288
|
+
|
|
289
|
+
Tracking via shared state:
|
|
290
|
+
state_write(mode: "cost-budget", state: {
|
|
291
|
+
"wave_id": "wave-2",
|
|
292
|
+
"pane_id": "pane-3",
|
|
293
|
+
"pane_cost": "1.25",
|
|
294
|
+
"wave_budget": "5.60"
|
|
295
|
+
})
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Wave-Level Threshold Checks
|
|
299
|
+
|
|
300
|
+
After each pane completes, check the wave aggregate:
|
|
301
|
+
|
|
302
|
+
```
|
|
303
|
+
1. Pane completes → reports cost to shared state
|
|
304
|
+
2. Orchestrator reads all pane costs for current wave
|
|
305
|
+
3. Calculate: wave_spent = sum(all pane costs)
|
|
306
|
+
4. Check: wave_spent vs wave_budget
|
|
307
|
+
5. If WARN → alert, continue remaining panes
|
|
308
|
+
6. If CRITICAL → let running panes finish, block next wave
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
## Verification Checklist
|
|
314
|
+
|
|
315
|
+
Before starting an autonomous workflow:
|
|
316
|
+
|
|
317
|
+
- [ ] Budget is declared (`COST_BUDGET_USD` or config)
|
|
318
|
+
- [ ] Scope is appropriate (`session` / `wave` / `project`)
|
|
319
|
+
- [ ] Thresholds are configured (default: 50/80/100%)
|
|
320
|
+
- [ ] Alert channels are set up (terminal is automatic)
|
|
321
|
+
- [ ] Webhook URL is valid (if using webhook alerts)
|
|
322
|
+
- [ ] Override protocol is understood by the operator
|
|
323
|
+
|
|
324
|
+
During execution:
|
|
325
|
+
|
|
326
|
+
- [ ] Cost is tracked per request
|
|
327
|
+
- [ ] Thresholds trigger correct alert level
|
|
328
|
+
- [ ] WARN alerts appear in terminal
|
|
329
|
+
- [ ] CRITICAL threshold pauses the workflow
|
|
330
|
+
- [ ] State is saved before pause
|
|
331
|
+
- [ ] Override resumes workflow correctly
|
|
332
|
+
|
|
333
|
+
After completion:
|
|
334
|
+
|
|
335
|
+
- [ ] Total cost is logged
|
|
336
|
+
- [ ] Cost breakdown is available (per-session, per-wave)
|
|
337
|
+
- [ ] Budget vs actual comparison is recorded
|
|
338
|
+
|
|
339
|
+
## Red Flags — STOP
|
|
340
|
+
|
|
341
|
+
| Thought | Reality |
|
|
342
|
+
|---------|---------|
|
|
343
|
+
| "It's just a quick autopilot run, no budget needed" | Quick runs become long runs. Set a budget. |
|
|
344
|
+
| "I'll check the cost later" | Later is after the money is spent. Track now. |
|
|
345
|
+
| "The budget is too small, I'll just override" | If you're always overriding, your budget is wrong. Increase it properly. |
|
|
346
|
+
| "Token counting is too much overhead" | API responses include token counts. No extra cost to read them. |
|
|
347
|
+
| "I'll skip the webhook, terminal alerts are enough" | You won't see terminal alerts if you walk away. Set up webhooks for unattended runs. |
|
|
348
|
+
| "One pane won't affect the total budget much" | Parallel panes multiply cost linearly. 8 panes = 8x the cost rate. |
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cross-repo-issues
|
|
3
|
+
description: Use when a bug or feature request belongs in an upstream, parent, or dependency repository rather than the current one. Guides detection, mapping, and safe cross-repo issue creation with user confirmation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Cross-Repo Issue Creation
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Not every issue belongs in the repository where it was discovered. Bugs in forked code belong upstream. Problems in a monorepo dependency belong in that dependency's repo. Filing issues in the wrong place wastes maintainer time and delays fixes.
|
|
11
|
+
|
|
12
|
+
**Core principle:** ALWAYS confirm the target repository with the user before creating an issue elsewhere. Never auto-create issues in repositories you don't own.
|
|
13
|
+
|
|
14
|
+
**Iron Law:**
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
NO CROSS-REPO ISSUE CREATION WITHOUT EXPLICIT USER CONFIRMATION
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## When to Use
|
|
21
|
+
|
|
22
|
+
- Bug discovered in forked code that should be reported upstream
|
|
23
|
+
- Issue in a monorepo sub-package that belongs in the package's source repo
|
|
24
|
+
- Bug in a third-party dependency that should be filed in the library's repo
|
|
25
|
+
- Feature request that affects an upstream project
|
|
26
|
+
- Security vulnerability that needs to be reported to the upstream maintainer
|
|
27
|
+
|
|
28
|
+
**Use this ESPECIALLY when:**
|
|
29
|
+
- Working in a fork and the bug exists in the original repo
|
|
30
|
+
- A monorepo package wraps an external library and the bug is in the library
|
|
31
|
+
- You need to coordinate fixes across multiple repositories
|
|
32
|
+
|
|
33
|
+
## When NOT to Use
|
|
34
|
+
|
|
35
|
+
- Issue is local to the current repository (use normal issue workflow)
|
|
36
|
+
- You don't have access to the target repository
|
|
37
|
+
- The upstream project is archived or unmaintained
|
|
38
|
+
- Simple configuration issues that are project-specific
|
|
39
|
+
|
|
40
|
+
## Configuration
|
|
41
|
+
|
|
42
|
+
Add `upstreamRepos` to your `codingbuddy.config.json`:
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"upstreamRepos": {
|
|
47
|
+
".": "original-owner/original-repo",
|
|
48
|
+
"packages/ui": "design-system/ui-kit",
|
|
49
|
+
"dep:react": "facebook/react"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Key Conventions
|
|
55
|
+
|
|
56
|
+
| Key Pattern | Meaning | Example |
|
|
57
|
+
|-------------|---------|---------|
|
|
58
|
+
| `"."` | Current repo is a fork of this upstream | `"original-owner/repo"` |
|
|
59
|
+
| `"packages/..."` | Monorepo package maps to external repo | `"org/package-repo"` |
|
|
60
|
+
| `"dep:<name>"` | npm/pip dependency maps to its source repo | `"facebook/react"` |
|
|
61
|
+
|
|
62
|
+
### Minimal Configuration
|
|
63
|
+
|
|
64
|
+
For a simple fork, only one entry is needed:
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"upstreamRepos": {
|
|
69
|
+
".": "upstream-owner/upstream-repo"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## The Three Phases
|
|
75
|
+
|
|
76
|
+
### Phase 1: Detect — Identify Where the Issue Belongs
|
|
77
|
+
|
|
78
|
+
**Determine if the issue should go to another repository:**
|
|
79
|
+
|
|
80
|
+
1. **Check the code origin**
|
|
81
|
+
- Is the buggy code from an upstream repo? (`git log --follow <file>`)
|
|
82
|
+
- Is it in a vendored or forked dependency?
|
|
83
|
+
- Does `git remote -v` show an upstream remote?
|
|
84
|
+
|
|
85
|
+
2. **Check the config mapping**
|
|
86
|
+
- Read `upstreamRepos` from `codingbuddy.config.json`
|
|
87
|
+
- Match the affected file path or package name to a mapping key
|
|
88
|
+
- If no mapping exists, ask the user for the target repo
|
|
89
|
+
|
|
90
|
+
3. **Verify the issue doesn't already exist upstream**
|
|
91
|
+
- Search upstream issues: `gh issue list -R <upstream> --search "<keywords>"`
|
|
92
|
+
- Check for duplicates before creating
|
|
93
|
+
|
|
94
|
+
**Decision matrix:**
|
|
95
|
+
|
|
96
|
+
| Scenario | Target Repo | Key |
|
|
97
|
+
|----------|-------------|-----|
|
|
98
|
+
| Bug in forked code | Upstream repo | `"."` |
|
|
99
|
+
| Bug in monorepo sub-package's upstream | Package source repo | `"packages/<name>"` |
|
|
100
|
+
| Bug in third-party dependency | Library repo | `"dep:<package>"` |
|
|
101
|
+
| Bug in your own code | Current repo (stop here) | N/A |
|
|
102
|
+
|
|
103
|
+
**Completion criteria:**
|
|
104
|
+
- [ ] Target repository identified
|
|
105
|
+
- [ ] Duplicate check completed
|
|
106
|
+
- [ ] Issue is confirmed to belong upstream
|
|
107
|
+
|
|
108
|
+
### Phase 2: Confirm — Get User Approval
|
|
109
|
+
|
|
110
|
+
**MANDATORY: Never skip this phase.**
|
|
111
|
+
|
|
112
|
+
Present the following to the user before proceeding:
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
Cross-Repo Issue Detected:
|
|
116
|
+
Source: <current-repo> (<file-or-package>)
|
|
117
|
+
Target: <upstream-repo>
|
|
118
|
+
Reason: <why this belongs upstream>
|
|
119
|
+
Title: <proposed issue title>
|
|
120
|
+
|
|
121
|
+
Proceed with creating issue in <upstream-repo>? (y/n)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Include in the confirmation:**
|
|
125
|
+
- The exact target repository (`owner/repo`)
|
|
126
|
+
- Why the issue belongs there (not here)
|
|
127
|
+
- Proposed issue title and summary
|
|
128
|
+
- Whether user has write access to the target repo
|
|
129
|
+
|
|
130
|
+
**If user declines:**
|
|
131
|
+
- Offer to create the issue in the current repo instead
|
|
132
|
+
- Add a label like `upstream` or `external-dependency` for tracking
|
|
133
|
+
|
|
134
|
+
**Completion criteria:**
|
|
135
|
+
- [ ] User explicitly confirmed target repo
|
|
136
|
+
- [ ] User approved issue title and content
|
|
137
|
+
|
|
138
|
+
### Phase 3: Create — File the Issue
|
|
139
|
+
|
|
140
|
+
**Create the issue in the confirmed target repository:**
|
|
141
|
+
|
|
142
|
+
1. **Format the issue body**
|
|
143
|
+
|
|
144
|
+
```markdown
|
|
145
|
+
## Description
|
|
146
|
+
|
|
147
|
+
<Clear description of the issue>
|
|
148
|
+
|
|
149
|
+
## Reproduction
|
|
150
|
+
|
|
151
|
+
- Repository: <your-repo> (discovered while working on <context>)
|
|
152
|
+
- File/Package: <affected file or package>
|
|
153
|
+
- Steps to reproduce: <steps>
|
|
154
|
+
|
|
155
|
+
## Expected Behavior
|
|
156
|
+
|
|
157
|
+
<what should happen>
|
|
158
|
+
|
|
159
|
+
## Actual Behavior
|
|
160
|
+
|
|
161
|
+
<what actually happens>
|
|
162
|
+
|
|
163
|
+
## Environment
|
|
164
|
+
|
|
165
|
+
- Version: <upstream version in use>
|
|
166
|
+
- OS: <if relevant>
|
|
167
|
+
|
|
168
|
+
## Additional Context
|
|
169
|
+
|
|
170
|
+
Discovered in downstream repo: <your-repo-url>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
1. **Create the issue**
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
gh issue create -R <owner/repo> \
|
|
177
|
+
--title "<title>" \
|
|
178
|
+
--body "<body>"
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
1. **Link back to current repo (optional)**
|
|
182
|
+
- Create a tracking issue in current repo referencing the upstream issue
|
|
183
|
+
- Add label: `blocked-upstream` or `waiting-upstream`
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
gh issue create \
|
|
187
|
+
--title "Tracking: <upstream-owner/repo>#<number>" \
|
|
188
|
+
--body "Upstream issue: <url>\nBlocked until upstream fix is available." \
|
|
189
|
+
--label "blocked-upstream"
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**Completion criteria:**
|
|
193
|
+
- [ ] Issue created in target repository
|
|
194
|
+
- [ ] Issue URL shared with user
|
|
195
|
+
- [ ] (Optional) Tracking issue created in current repo
|
|
196
|
+
|
|
197
|
+
## Quick Reference
|
|
198
|
+
|
|
199
|
+
| Phase | Action | Verification |
|
|
200
|
+
|-------|--------|-------------|
|
|
201
|
+
| **1. Detect** | Identify target repo from config or code origin | Target repo confirmed |
|
|
202
|
+
| **2. Confirm** | Present plan to user, get explicit approval | User said yes |
|
|
203
|
+
| **3. Create** | File issue via `gh`, link back if needed | Issue URL available |
|
|
204
|
+
|
|
205
|
+
## Safety Checklist
|
|
206
|
+
|
|
207
|
+
Before creating any cross-repo issue:
|
|
208
|
+
|
|
209
|
+
- [ ] Target repo is correct (double-check `owner/repo`)
|
|
210
|
+
- [ ] Issue doesn't already exist upstream (searched)
|
|
211
|
+
- [ ] User explicitly approved the creation
|
|
212
|
+
- [ ] Issue body is professional and includes reproduction steps
|
|
213
|
+
- [ ] No sensitive/proprietary information in the issue body
|
|
214
|
+
- [ ] You have access to create issues in the target repo
|
|
215
|
+
|
|
216
|
+
## Red Flags — STOP
|
|
217
|
+
|
|
218
|
+
| Thought | Reality |
|
|
219
|
+
|---------|---------|
|
|
220
|
+
| "I'll just create it, the user won't mind" | STOP. Always confirm. Cross-repo actions are visible to external maintainers. |
|
|
221
|
+
| "It's obviously an upstream bug" | Maybe. But confirm the target repo with the user first. |
|
|
222
|
+
| "I'll skip the duplicate check" | Duplicate issues waste maintainer time and hurt your credibility. |
|
|
223
|
+
| "The config mapping is enough confirmation" | Config maps repos, but the user must confirm each issue creation. |
|
|
224
|
+
| "I'll include our internal details for context" | STOP. Review for sensitive information before posting to external repos. |
|
|
225
|
+
| "No config? I'll guess the upstream repo" | Ask the user. Wrong repo = noise for unrelated maintainers. |
|
|
226
|
+
|
|
227
|
+
## Examples
|
|
228
|
+
|
|
229
|
+
### Fork → Upstream
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
Config: { "upstreamRepos": { ".": "expressjs/express" } }
|
|
233
|
+
|
|
234
|
+
Detected: Bug in request parsing (inherited from upstream)
|
|
235
|
+
Target: expressjs/express
|
|
236
|
+
Action: Confirm with user → Create issue in expressjs/express
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Monorepo Package → Source Repo
|
|
240
|
+
|
|
241
|
+
```
|
|
242
|
+
Config: { "upstreamRepos": { "packages/icons": "design-org/icon-library" } }
|
|
243
|
+
|
|
244
|
+
Detected: Missing icon in packages/icons (sourced from design-org/icon-library)
|
|
245
|
+
Target: design-org/icon-library
|
|
246
|
+
Action: Confirm with user → Create issue in design-org/icon-library
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Dependency → Library Repo
|
|
250
|
+
|
|
251
|
+
```
|
|
252
|
+
Config: { "upstreamRepos": { "dep:zod": "colinhacks/zod" } }
|
|
253
|
+
|
|
254
|
+
Detected: Validation bug in zod usage
|
|
255
|
+
Target: colinhacks/zod
|
|
256
|
+
Action: Confirm with user → Search existing issues → Create if new
|
|
257
|
+
```
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: database-migration
|
|
3
3
|
description: Use when performing database schema changes, data migrations, large table modifications, or when zero-downtime deployment is required - guides systematic, reversible database changes with rollback planning
|
|
4
|
+
disable-model-invocation: true
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
# Database Migration
|