You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -84,4 +115,161 @@ docker-compose up -d # Start local DBs
84
115
-`task_query`
85
116
-`recover_on_low_signal: true`
86
117
- Do not fetch raw `get_conversation` context for worker execution unless full transcript behavior is explicitly required.
87
-
- The current assignment is persisted under `.stackmemory/worker-context/current-assignment.json` so wrappers and hooks can auto-fill or enforce `task_query`.
118
+
- The current assignment is persisted under `.stackmemory/worker-context/current-assignment.json` so wrappers and hooks can auto-fill or enforce `task_query`.
119
+
120
+
## Security
121
+
122
+
NEVER hardcode secrets - use process.env with dotenv/config
For AUTOMATE and STANDARD tiers: make only the requested changes. Don't refactor surrounding code, add abstractions for one-time operations, or create helpers that are used once. Three similar lines of code is better than a premature abstraction.
216
+
217
+
## Cost Optimization
218
+
219
+
Assume token costs only go up: Max-plan usage ramps from ~80% off to full price over ~3 months (codified in `src/core/models/provider-pricing.ts` → `MAX_PLAN_DISCOUNT_RAMP` / `effectiveSpendMultiplier()`). The cheapest token is the one you don't send. Full playbook: `docs/cost-optimization.md`.
220
+
221
+
Codified defaults (cheapest lever first):
222
+
-**Route by complexity.** Keep `multiProvider` on — `getOptimalProvider()`/`scoreComplexity()` send simple tasks to cheap models, hard ones to Anthropic. Opus only for CAREFUL/ARCHITECT; Sonnet default; Haiku/cheap providers for AUTOMATE. Output tokens cost 5× input.
223
+
-**Tune `effort` before model.** Default `high` for coding; `medium` for cost-sensitive; `max`/`xhigh` only for correctness-critical. Pair with adaptive thinking.
224
+
-**Protect the prompt cache.** Keep the prefix byte-stable — no timestamps/UUIDs/IDs in the system prompt, no mid-session tool/model swaps (full rebuild). Cache reads are ~0.1×.
225
+
-**Batch non-interactive work** via `AnthropicBatchClient` (50% off).
226
+
-**Cap context** via `ContextBudgetManager`; keep the token-optimization hooks on (dedup/prewarm/script-suggest).
Guardrails (never trade for cost): the sensitive-content guard must keep forcing Anthropic for secrets/PII; correctness tiers stay on the capable model; never truncate inputs silently — cap deliberately via the budget manager.
230
+
231
+
## Session Budget
232
+
233
+
- Max 1 major topic per session — split unrelated work into separate sessions
234
+
- Run /compact or summarize at ~50% context usage to avoid overflow
235
+
- Plan-execute sessions (low interaction, high edits) are most efficient
236
+
- Avoid exploratory marathons with topic-switching — burns 30-40% extra tokens
237
+
238
+
## Context Maintenance
239
+
240
+
**`/update-docs`** — Run weekly or when context feels stale:
241
+
- Audits CLAUDE.md, MEMORY.md, agent_docs/ against git history and codebase
242
+
- Detects stale entries, missing patterns, outdated paths
243
+
- Trigger: start of week, after major refactors, or when sessions feel slow/confused
244
+
245
+
**`/recover`** — Run when a session goes off the rails:
246
+
- Analyzes traces to find where context drifted from intent
247
+
- Maps drift to specific doc fixes (missing guidance, stale memory, ambiguous instruction)
248
+
- Trigger: user says "this is wrong", "not what I wanted", "off the rails", repeated corrections
249
+
250
+
**`/next`** — Run at session start or when asking "what's next":
251
+
- Scans git log, TODO files, Linear issues, and memory for actionable items
0 commit comments