brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
core-context-compressorUse this skill when the user says 'compress context', 'context summary', 'token save', 'compression', 'condense', 'summarize conversation', 'context budget', 'reduce tokens', 'context window'. Produces a structured compressed summary of current session context. Do NOT use for: general note-taking or file writing.
Independent GitHub snapshot · Automated classification · Original documentation governs
Compress long conversation histories into structured, token-efficient summaries for continuing work within context window limits. Extracts decisions, file changes, configuration values, and next steps into bullet-point format optimized for AI agent consumption.
LLMs have finite context windows (~32K-200K tokens). As conversations grow over dozens of exchanges, quality degrades because relevant information is buried. This skill produces a lossy-but-critical compression sacrificing implementation detail while preserving every decision, file change, configuration value, and unresolved question.
"compress context", "context summary", "token save", "compression", "condense", "summarize conversation", "context budget", "reduce tokens", "context window"
Structured compressed summary with exactly 5 sections: Decisions, Files Changed, Current State, Next Steps, Open Questions. Maximum 50 lines.
path/file.ts:startLine-endLine + brief change description1000 tokens
Remove oldest conversation exchanges while keeping most recent N exchanges. Sliding window keeps last M exchanges (default M=10) plus exchanges containing key decisions, file changes, or configuration settings. Lossy but fast — no processing beyond counting exchanges and identifying decision-bearing messages. Use as first pass before more sophisticated strategies.
Replace verbose exchanges with condensed bullet-point summaries. Each exchange reduced to essential info: user request, action taken, result, decisions made. A 20-line debugging exchange becomes Debugged PG connection timeout — increased pool to 20, added connection retry with 3 attempts. Most common strategy, works well for mixed technical and explanatory content.
Organize compressed information by topic/domain rather than chronologically. Group all DB decisions together, all config changes together, all file modifications together. Useful when conversation spans multiple independent topics (backend, frontend, infrastructure) or when same file was modified multiple times. Apply when conversation covers 3+ distinct domains.
Assign each info item a priority score based on impact on future work:
When conversation history exceeds 50 exchanges or 40K tokens, process in chunks of 20-30 exchanges. Compress each chunk independently. Merge segment summaries into single output, applying priority scoring to decide what to keep from each segment. Prevents context overflow during compression itself.
For conversations spanning multiple compressed sessions, merge previous summary's Decisions, Open Questions, and Current State with new history. Conflicts resolved by preferring most recent decision. Duplicates deduplicated. Merged output must still fit within 50 lines.
Analyze current context — Scan full conversation history systematically. Identify every key decision (what, why, alternatives rejected) → Decisions section. Identify every modified file with line ranges and change descriptions → Files Changed. Identify current position in workflow → single-line Current State. Identify all next steps ordered by dependency → Next Steps. Identify all unresolved questions, blockers, pending decisions → Open Questions.
Extract essential information — Technology choices (language, framework, database, queue, cache, infra service + why). Architecture decisions (structural choices, tradeoffs accepted, what was rejected). Configuration values (every env var, port, URL, connection string, feature flag). Bug root causes (what caused it, how fixed, tests added). User preferences (naming, indentation, semicolons, test framework, architecture patterns).
Compress format aggressively — Bullet points exclusively. Strip all articles (the, a, an). Use consistent abbreviations. Use key-value pairs: PORT=3000. Use arrow notation for causality: chose PG → JSONB support needed. Use parentheses for alternatives: chose PG (alt: MySQL — rejected: no JSONB). No bold, italics, blockquotes, or decorative markdown.
Output structured summary — 5 markdown H2 sections. Decisions: every decision with rationale, err on inclusion. Files Changed: sorted alphabetically by path. Current State: single line. Next Steps: numbered, ordered by dependency. Open Questions: each = {question} → blocks {blocked item}. Count lines. If over 50, sacrifice implementation specifics (line numbers, variable names, test assertions) before removing any decision or question.
Each piece of information:
├── Affects future decisions? → Keep in Decisions
├── Identifies what was changed? → Keep in Files Changed
├── Describes where we are? → Keep in Current State
├── Tells us what to do next? → Keep in Next Steps
├── Is an unresolved blocker? → Keep in Open Questions (ALWAYS)
└── Is implementation noise/detail? → Discard
Conversation length:
├── <20 exchanges → Truncation (keep last 10 + key exchanges)
├── 20-50 exchanges → Summarization + Priority Scoring
├── 50-100 exchanges → Streaming (chunks of 20-30) + Merge + Priority Scoring
└── 100+ exchanges → Streaming + Hierarchical + Priority Scoring
After compression → Count lines:
├── ≤50 → Add footer → Done
├── >50 → Apply Priority Scoring → Remove lowest priority
└── Still >50 → Re-compress → Merge related → Trim again
Conversation type:
├── Debugging → P1: root cause, P1: fix, P2: tests, P3: debug steps, P4: tools
├── Code Generation → P1: file paths, P1: arch decisions, P2: patterns, P2: deviations, P3: tests
├── Code Review → P1: review decisions per file, P1: issues+severity, P2: refactor plans, P1 (Open Q): unresolved
└── Architecture Design → P1: final decision, P1: alternatives+rationale, P2: tradeoffs, P2: boundaries, P1: next steps
| Full Term | Abbreviation | Full Term | Abbreviation |
|---|---|---|---|
| Configuration | config | Environment | env |
| Authentication | auth | Authorization | authz |
| Documentation | docs | Dependency | dep |
| Repository | repo | Implementation | impl |
| Development | dev | Production | prod |
| Established | est | Benchmark | bench |
| Migration | mig | Integration | int |
| Deployment | deploy | Service | svc |
| Category | Priority | Always Include | Compress First |
|---|---|---|---|
| Tech decisions | 1 | Language, framework, database choice | Rationale detail |
| Config values | 1 | PORT, DB_URL, API_KEY, feature flags | Comments, history |
| Architecture | 2 | Structural choices, module boundaries | Implementation details |
| Bug fixes | 2 | Root cause, fix approach, test added | Stack traces, debug output |
| File changes | 3 | File path, change description | Minor change exact line numbers |
| Progress | 4 | Current state line | Everything |
| Verbose Original | Compressed |
|---|---|
| We decided to use PostgreSQL because it has better JSONB support for our flexible schema requirements. | PG over MySQL — JSONB support needed |
| The user should set the LOG_LEVEL env var to debug to get more verbose logging. | LOG_LEVEL=debug |
| We modified the auth middleware to check for JWT tokens in the Authorization header instead of the cookie. | auth middleware: JWT check moved from cookie to Authorization header |
| After discussing with the team, we increased the timeout from 10 seconds to 30 seconds to handle the new batch endpoint. | timeout 10s → 30s (batch endpoint needs it) |
| We added a new route handler for the password reset endpoint in the auth controller. | auth: added password reset route |
| The user prefers 2-space indentation and single quotes for strings. | style: 2-space indent, single quotes |
| We fixed the null pointer exception in UserService.findByEmail by adding a null check before accessing the email property. | fix: UserService.findByEmail — added null check |
[DB], [Auth], [API], [FE], [Infra][DB] PG over MySQL — JSONB supportsrc/routes/*.ts — added CRUD endpoints+ : + src/auth/middleware.ts:1-50 — JWT check<domain>: <action-completed>. <next-milestone> pending.Auth: JWT middleware done. User CRUD pending.{question} → blocks {what it blocks}No open questions. — never omit the section[Auth] JWT refresh strategy? → blocks token management impl.Before delivering compressed summary, verify:
<project_context_summary>
Project: {name}
Goal: {current objective}
Phase: {phase} — {progress summary}
#### Active State
- Last files: {path1}, {path2}, {path3}
- Open decisions: {decision1}, {decision2}
- Current branch: {branch_name}
- Build status: {passing/failing details}
#### Architecture Snapshot
{3-5 sentence summary of current architecture understanding}
#### Key Decisions Made
- {decision}: {rationale} (timestamp)
- {decision}: {rationale} (timestamp)
#### Next Actions (priority order)
1. {action} — {why now}
2. {action} — {depends on context}
3. {action} — {low priority / stretch}
#### Unresolved Questions
- {question} — {who needs to answer}
- {question} — {blocker if not resolved}
#### Relevant References
- {filepath} — {why it matters}
- {filepath} — {why it matters}
#### Token Budget
- Context remaining: ~{n} tokens
- Next session should first: {rehydrate from summary}
</project_context_summary>
| Available Tokens | Strategy | Detail Level |
|---|---|---|
| 100k+ (full context) | Full session summary with code snippets | Max — all decisions, commits, references |
| 50-100k | Compressed summary, key code, open questions | Medium — drop verbose logs, partial code |
| 10-50k | Bullet points only, no code blocks | Minimal — decisions + next actions |
| < 10k | 3-line TL;DR only | Critical — scope + next step |
Before saving a compressed summary, verify:
Good compression (complex project):
<project_context_summary>
Project: j4flmao-org
Goal: Add OAuth2 PKCE flow to auth module
Phase: Implementation — 70% complete
#### Active State
- Last files: src/auth/oauth.ts, src/auth/tokens.ts, tests/auth/oauth.test.ts
- Open decisions: Token refresh strategy (sliding vs absolute expiry)
- Current branch: feat/oauth-pkce
- Build status: 15/18 tests passing (3 need token refresh mock)
#### Architecture Snapshot
OAuth flow uses PKCE with S256 challenge method. Auth service orchestrates
authorize → callback → token exchange → refresh cycle. Tokens stored in
HttpOnly cookies with CSRF token in header. Backend verifies code_verifier
against stored code_challenge before issuing tokens.
#### Key Decisions Made
- PKCE S256 over plain: more secure, prevents verifier interception
- HttpOnly cookies: prevents XSS token theft, requires CSRF header
- Sliding refresh tokens: better UX, 7-day absolute expiry limit
#### Next Actions (priority order)
1. Implement token refresh interceptor in fetch wrapper
2. Add CSRF token generation endpoint (/api/auth/csrf)
3. Write integration test for full refresh flow
4. Handle token expiry edge case (both expired)
#### Unresolved Questions
- Should refresh token rotate? (security vs UX tradeoff)
- Cookie same-site policy: Lax or Strict? (CSRF risk vs UX)
#### Token Budget
- Context remaining: ~12k tokens
- Next session: Rehydrate from this summary, focus on refresh interceptor
</project_context_summary>
Over-compressed (bad — not actionable):
<summary>Working on auth. Need to do more stuff. Check the files.</summary>
Under-compressed (bad — defeats purpose):
<summary>
[200 lines of raw conversation history with no structure]
</summary>
master-orchestrator
│
├──→ context-compressor (compress session → update context file)
│ │
│ └──→ context-file.md (persistent, version-controlled)
│
└──→ master-orchestrator (next session reads context file)
│
└──→ [decide] → continue work OR new task
git checkout triggers context snapshotWhen loading a compressed summary in a new session:
| Anti-Pattern | Why It Fails | Better Approach |
|---|---|---|
| Including raw logs | Wastes tokens, obscures signal | Summarize outcomes: "Build failed: 3 test failures, all in auth module" |
| Stale summaries | Read old context, make wrong decisions | Always update before session end. Treat as append-only log. |
| Subjective language | "We're almost done" means nothing | "5 files modified, 3 of 10 tests passing" — quantify everything |
| No ownership | Questions no one answers get forgotten | Always tag: "(decide with: @product)" or "(blocked: waiting on David)" |
| Missing file paths | "Update the function" — which function, which file? | Always src/auth/oauth.ts:42 — exact references |
| Copy-paste of commit messages | Repeats what git log already has | Synthesize: "3 commits refactored auth middleware for PKCE support" |
| Over-tokenization | Full code blocks in summary — uses 80% of budget | Link to files, describe changes, don't paste entire functions |
| No rehydration step | Jump into work, miss context, duplicate decisions | Always read the context file and verify state first |
Context Compression Strategy
├── Session length?
│ ├── > 2 hours → Summarize by phase (planning, implementation, debugging)
│ ├── < 30 min → Single block summary with key decisions
│ └── Multi-session → Cross-reference with prior session summaries
├── Decision density?
│ ├── High (architecture changes) → Detailed ADR-style entries
│ ├── Medium (implementation) → What/Why, not How
│ └── Low (bug fixes) → Symptom + root cause + fix path
└── Collaboration type?
├── Solo → Technical decisions + next steps
└── Team → Ownership tags + blocked items for async resolution
Decision criteria: Balance token budget (target < 2k tokens for summary), reader time, and completeness.
# Context Summary: 2024-06-21
## Progress
- `src/auth/oauth.ts`: Implemented PKCE flow (3 commits)
- `tests/auth.test.ts`: Added 8 test cases, 6 passing, 2 flaky (rate-limited)
## Decisions
- Use @opencode/logger instead of winston (lighter, native ESM)
- Rejected: gRPC for auth service → REST is sufficient for < 10 req/s
## Blocked
- Awaiting: CDN SSL cert from DevOps (@david, ticket OPS-442)
- Pending: Design review for dashboard widget API (due Fri)
{
"timestamp": "2024-06-21T14:30:00Z",
"type": "architecture",
"title": "Choose logging framework",
"context": "Need structured logging for auth service",
"options": ["winston", "pino", "@opencode/logger"],
"decision": "@opencode/logger",
"rationale": "Native ESM, 40% less bundle size, active maintenance",
"rejected": ["gRPC for auth service"],
"tags": ["auth", "logging"]
}
(@person) for accountability.active, superseded, or rejected with dates.| Anti-Pattern | Consequence | Solution |
|---|---|---|
| Over-tokenization | 80% of budget on code blocks | Link to files, describe changes |
| No ownership | Unresolved blockers | Always tag (@person) |
| Subjective language | Ambiguous next steps | Quantify everything |
| Missing file paths | Can't find what changed | Always src/path/file.ts:42 |
| Copy-paste commits | Redundant with git log | Synthesize, don't repeat |
| No rehydration | Duplicate decisions | Read context file first |
master-orchestrator — the compressed summary is injected at the start of the next work session for the master orchestrator skill to continue the work from where it was interrupted.