codexkit 1.0.3 → 1.0.5

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.
@@ -1,10 +1,11 @@
1
1
  ---
2
2
  name: compaction
3
3
  description: >
4
- Use when context is growing large during long-running tasks and needs server-side or client-side
5
- summarization to continue effectively. Covers compaction triggers, custom summarization patterns,
6
- session handoff, and context preservation strategies.
7
- version: 1.0.0
4
+ Use when context is growing large during long-running tasks and needs
5
+ summarization to continue effectively. Covers compaction triggers, custom
6
+ summarization patterns, session handoff, and context preservation strategies.
7
+ Uses Codex-native /compact command.
8
+ version: 2.0.0
8
9
  tags: [context, workflow]
9
10
  dependencies: []
10
11
  ---
@@ -19,7 +20,6 @@ dependencies: []
19
20
 
20
21
  - Short sessions with low context usage where no compaction is needed.
21
22
 
22
-
23
23
  ## Overview
24
24
 
25
25
  **Compaction = Summarization + Preservation + Continuity**
@@ -32,54 +32,53 @@ Long-running sessions accumulate context (tool outputs, code reads, exploration
32
32
 
33
33
  | Context Usage | Status | Action |
34
34
  | ------------- | ----------- | --------------------------------------------- |
35
- | 0-50% | 🟢 Normal | Work freely |
36
- | 50-70% | 🟡 Watch | Start compressing completed explorations |
37
- | 70-85% | 🟠 Compact | Actively compress and sweep stale noise |
38
- | 85-95% | 🔴 Critical | Emergency compaction, prepare session handoff |
39
- | 95%+ | Limit | Session handoff required |
35
+ | 0-50% | Normal | Work freely |
36
+ | 50-70% | Watch | Start compressing completed explorations |
37
+ | 70-85% | Compact | Actively compress; write summaries to durable files |
38
+ | 85-95% | Critical | Emergency compaction, prepare session handoff |
39
+ | 95%+ | Limit | Session handoff required |
40
40
 
41
41
  ### Monitoring
42
42
 
43
43
  Pay attention to these signals:
44
44
 
45
- - Completed phases accumulating without being compressed
45
+ - Completed phases accumulating without being summarized
46
46
  - Repeated file reads of the same content
47
47
  - Large bash outputs from builds/tests
48
48
  - Multiple exploration rounds without synthesis
49
49
 
50
50
  ## Compaction Strategies
51
51
 
52
- ### Strategy 1: Phase Compression (Preferred)
53
-
54
- Compress completed conversation phases into dense summaries. This is the primary DCP instrument in the installed beta.
52
+ ### Strategy 1: Codex-Native `/compact` (Preferred)
55
53
 
56
-
57
- Compress completed conversation phases into dense summaries.
54
+ Use the built-in `/compact` command to summarize conversation history while preserving key context.
58
55
 
59
56
  ```
60
- WHEN: A research phase is complete and findings are clear
61
- DO: compress({
62
- topic: "Auth Research Complete",
63
- content: {
64
- startString: "unique text at phase start",
65
- endString: "unique text at phase end",
66
- summary: "Complete technical summary of findings..."
67
- }
68
- })
57
+ WHEN: A research or implementation phase is complete
58
+ DO: /compact focus on [completed phase topic]
69
59
  ```
70
60
 
71
- **Key principle**: Only compress CLOSED chapters. Never compress active work.
61
+ The `/compact` command:
62
+ - Summarizes conversation history server-side
63
+ - Preserves key decisions and findings
64
+ - Frees context budget for new work
65
+ - Accepts an optional focus instruction to guide what it preserves
72
66
 
73
- ### Strategy 2: Sweep Stale Noise
67
+ **Key principle**: Only compact CLOSED chapters. Never compact active work.
74
68
 
75
- Use `/dcp sweep` after a phase is complete to remove stale/noisy content automatically.
69
+ ### Strategy 2: Manual Phase Summarization
70
+
71
+ When `/compact` is too broad, manually write a dense summary to a durable file before the context is lost.
76
72
 
77
73
  ```
78
- WHEN: Wrong-target searches or superseded outputs are no longer needed
79
- DO: /dcp sweep
74
+ WHEN: A research phase is complete and findings are clear
75
+ DO:
76
+ 1. Write summary to `.codex/context/worklog.md` or `.codex/memory/research/`
77
+ 2. Record key decisions in `.codex/context/decision-log.md`
78
+ 3. The summarized content can now be safely forgotten by the session
80
79
  ```
81
80
 
82
- **Key principle**: Sweep only after the relevant phase is closed. If in doubt, keep it.
81
+ **Key principle**: Persist durable findings to repo files before they leave the context window.
83
82
 
84
83
  ### Strategy 3: Session Handoff
85
84
 
@@ -88,10 +87,10 @@ When context is too large to compact further, hand off to a new session.
88
87
  ```
89
88
  WHEN: Context > 85% and significant work remains
90
89
  DO:
91
- 1. Create handoff document with memory-update
92
- 2. Save all decisions with observation tool
93
- 3. Document current state and remaining work
94
- 4. Start new session with handoff reference
90
+ 1. Update `.codex/context/session-context.md` with exact stop point
91
+ 2. Update `.codex/memory/project/state.md` with durable state
92
+ 3. Append milestone to `.codex/context/worklog.md`
93
+ 4. Start new session with `/prompts:resume`
95
94
  ```
96
95
 
97
96
  ## Compaction Decision Tree
@@ -100,8 +99,8 @@ DO:
100
99
  Is context growing large?
101
100
  ├── NO → Continue working normally
102
101
  └── YES → What type of content is consuming space?
103
- ├── Completed conversation phases → COMPRESS
104
- ├── Stale/noisy closed-phase outputsSWEEP
102
+ ├── Completed conversation phases → /compact
103
+ ├── Research findings not yet persisted Write to memory/research/, then /compact
105
104
  └── Everything is still relevant → SESSION HANDOFF
106
105
  ```
107
106
 
@@ -150,9 +149,9 @@ Is context growing large?
150
149
 
151
150
  ### Verification
152
151
 
153
- - TypeScript: passing
154
- - Tests: 12/12 passing
155
- - Lint: no issues
152
+ - TypeScript: passing
153
+ - Tests: 12/12 passing
154
+ - Lint: no issues
156
155
 
157
156
  ### Remaining
158
157
 
@@ -187,131 +186,83 @@ Is context growing large?
187
186
 
188
187
  - Added null check in middleware (src/auth/middleware.ts:42)
189
188
  - Added token refresh attempt before rejecting (src/auth/refresh.ts)
190
- - Added test for expired token scenario (src/auth/**tests**/middleware.test.ts)
189
+ - Added test for expired token scenario (src/auth/tests/middleware.test.ts)
191
190
 
192
191
  ### Verification
193
192
 
194
- - Tests: all passing including new test
195
- - Manual: expired token now triggers refresh
193
+ - Tests: all passing including new test
194
+ - Manual: expired token now triggers refresh
196
195
  ```
197
196
 
198
197
  ## Session Handoff Protocol
199
198
 
200
199
  When you must hand off to a new session:
201
200
 
202
- ### 1. Create Handoff Document
201
+ ### 1. Persist Durable Findings
203
202
 
204
- ```typescript
205
- memory -
206
- update({
207
- file: "handoffs/YYYY-MM-DD-feature-name",
208
- content: `# Session Handoff: [Feature Name]
203
+ Write key findings and decisions to the appropriate repo files:
209
204
 
210
- ## Context
211
- [Why this session started, what was the goal]
205
+ - `.codex/context/session-context.md` — exact stop point and first next action
206
+ - `.codex/memory/project/state.md` durable current state and blockers
207
+ - `.codex/context/worklog.md` — milestone summary
208
+ - `.codex/context/decision-log.md` — architecture/workflow decisions with rationale
209
+ - `.codex/memory/research/*.md` — deep investigation notes
212
210
 
213
- ## Completed Work
214
- [What was done, files changed, decisions made]
211
+ ### 2. Create Handoff Summary
215
212
 
216
- ## Current State
217
- [Where things stand right now]
213
+ Use `/prompts:handoff` or write directly to `session-context.md`:
218
214
 
219
- ## Remaining Work
220
- [What still needs to be done]
221
-
222
- ## Key Decisions
223
- [Important choices made and why]
224
-
225
- ## Files Modified
226
- [List of all files changed with brief description]
227
-
228
- ## Gotchas
229
- [Things the next session should know]
230
- `,
231
- mode: "replace",
232
- });
233
- ```
215
+ ```markdown
216
+ ## Resume: [task-id]
234
217
 
235
- ### 2. Save Key Observations
236
-
237
- ```typescript
238
- observation({
239
- type: "decision",
240
- title: "Auth implementation approach",
241
- narrative: "Chose JWT with Redis sessions because...",
242
- facts: "JWT 15min expiry, Redis 24h TTL, bcrypt 12 rounds",
243
- concepts: "authentication, sessions, tokens",
244
- confidence: "high",
245
- });
218
+ - Branch: [branch]
219
+ - Commit: [short hash]
220
+ - Stop point: [exact step in progress]
221
+ - First next action: [single best next action]
222
+ - Blockers: [none or short list]
246
223
  ```
247
224
 
248
225
  ### 3. Resume in New Session
249
226
 
250
- ```typescript
251
- // In new session:
252
- memory - read({ file: "handoffs/YYYY-MM-DD-feature-name" });
253
- memory - search({ query: "auth implementation" });
254
- ```
227
+ ```bash
228
+ # Native Codex resume (thread-based):
229
+ codex resume
255
230
 
256
- ## Integration with DCP Plugin
257
-
258
- This project uses DCP-style context management for always-on context discipline:
259
-
260
- - **compress**: Phase-level conversation compression (primary DCP tool in the installed beta)
261
- - **/dcp sweep**: Cleanup command for stale/noisy content after a phase is complete
262
- - **Prunable-tools list**: Auto-injected into messages with token estimates
263
- - **Nudge system**: Reminders every N tool calls + critical limit warnings
264
-
265
- **Division of responsibility:**
266
-
267
- - **DCP plugin**: Context budget rules, tool guidance, prunable-tools list, nudges (always present via system prompt)
268
- - **Compaction workflow** (`.codex/context/session-context.md` + handoff/resume prompts): Session continuity, beads state, handoff recovery, post-compaction protocol
231
+ # Or file-based resume via Codexkit:
232
+ /prompts:resume [task-id]
233
+ ```
269
234
 
270
235
  ## Anti-Patterns
271
236
 
272
- ### Premature Compaction
273
-
274
- ```
275
- // DON'T compress a file you're about to edit
276
- compress({ ... }) // Loses exact line numbers you need
277
- edit({ ... }) // Now you can't find the right location
278
- ```
237
+ ### Premature Compaction
279
238
 
280
- **Fix**: Keep raw content while actively editing. Compress AFTER the edit phase.
239
+ Don't compact a file you're about to edit — you'll lose exact line numbers. Keep raw content while actively editing. Compact AFTER the edit phase.
281
240
 
282
- ### Compressing Active Work
241
+ ### Compacting Active Work
283
242
 
284
- ```
285
- // DON'T compress a conversation phase you might return to
286
- compress({ summary: "Explored auth options" })
287
- // Later: "Wait, which options did we consider?"
288
- ```
243
+ Don't compact a conversation phase you might return to. Only compact CLOSED chapters where findings are crystallized.
289
244
 
290
- **Fix**: Only compress CLOSED chapters where findings are crystallized.
245
+ ### Ignoring Context Growth
291
246
 
292
- ### Ignoring Context Growth
247
+ Don't let context grow unchecked until hitting limits. By the time you notice, emergency compaction loses information. Monitor regularly and compact at natural breakpoints.
293
248
 
294
- ```
295
- // DON'T let context grow unchecked until hitting limits
296
- // By the time you notice, emergency compaction loses information
297
- ```
249
+ ### Persisting Only to Session Memory
298
250
 
299
- **Fix**: Monitor regularly. Compress at natural breakpoints and use `/dcp sweep` after closed phases.
251
+ Don't rely on session history for durable findings. Write important decisions and state to repo-visible files before compacting, so they survive session boundaries.
300
252
 
301
253
  ## Checklist
302
254
 
303
255
  Before compacting:
304
256
 
305
257
  - [ ] Identified what type of content is consuming context
306
- - [ ] Chosen appropriate strategy (compress/sweep/handoff)
258
+ - [ ] Chosen appropriate strategy (/compact, manual summary, or handoff)
307
259
  - [ ] Verified raw content is no longer needed for active work
308
- - [ ] Captured all key details in the compression summary or handoff
309
- - [ ] Saved important decisions as observations
260
+ - [ ] Persisted key findings to durable repo files
310
261
  - [ ] Created handoff document if switching sessions
311
262
 
312
263
  During long sessions:
313
264
 
314
- - [ ] Compressing completed phases at natural breakpoints
315
- - [ ] Sweeping stale/noisy outputs after phase completion
265
+ - [ ] Running `/compact` at natural phase boundaries
266
+ - [ ] Writing durable findings to context/memory files before they leave the window
316
267
  - [ ] Monitoring context usage trends
317
268
  - [ ] Planning session handoff if approaching limits
@@ -1,14 +1,14 @@
1
1
  ---
2
2
  name: context-management
3
- description: Unified protocol for context health and session lifecycle management using DCP tools, thresholds, handoff, and resume workflows
4
- version: 2.0.0
3
+ description: Unified protocol for context health and session lifecycle management using Codex-native /compact, repo-visible memory files, thresholds, handoff, and resume workflows
4
+ version: 3.0.0
5
5
  tags: [context, workflow, session]
6
6
  dependencies: []
7
7
  ---
8
8
 
9
9
  # Context Management
10
10
 
11
- > **Replaces** manual context tracking and ad-hoc session management — unified protocol for context health across a session lifecycle
11
+ > Unified protocol for context health across a session lifecycle using Codex-native primitives.
12
12
 
13
13
  Use this skill to keep context useful from first turn to final handoff.
14
14
 
@@ -17,7 +17,7 @@ Use this skill to keep context useful from first turn to final handoff.
17
17
  - Context size is growing and you need to reduce noise without losing critical details
18
18
  - You are finishing a work phase and want to compress completed exploration/implementation
19
19
  - You are preparing `/handoff` or resuming a prior session
20
- - You need to recover relevant prior context with `find_sessions`, `read_session`, and memory files
20
+ - You need to recover relevant prior context from repo files or session history
21
21
 
22
22
  ## When NOT to Use
23
23
 
@@ -29,61 +29,69 @@ Use this skill to keep context useful from first turn to final handoff.
29
29
  Prefer **phase-level compression** over reactive cleanup.
30
30
 
31
31
  ```text
32
- compress > sweep > handoff
32
+ /compact > persist to files > handoff
33
33
  ```
34
34
 
35
- - **compress**: Best default when a phase is complete
36
- - **sweep**: Use `/dcp sweep` to clean stale/noisy content after completion
37
- - **handoff**: Use when context pressure remains high even after compression
35
+ - **/compact**: Use the Codex-native command when a phase is complete
36
+ - **persist**: Write durable findings to repo files before they leave the context window
37
+ - **handoff**: Use when context pressure remains high even after compaction
38
38
 
39
- ## DCP Command Usage
39
+ ## Codex-Native Compaction
40
40
 
41
- ### `/dcp compress`
41
+ ### `/compact`
42
42
 
43
- Use for completed chapters of work (research, implementation wave, review sweep).
43
+ The built-in Codex CLI command that summarizes conversation history server-side.
44
+
45
+ Use for completed chapters of work (research, implementation wave, review sweep):
46
+
47
+ ```
48
+ /compact focus on the authentication refactor
49
+ ```
44
50
 
45
51
  - Best for large ranges of now-stable outputs
46
52
  - Lowest cognitive overhead on later turns
53
+ - Accepts optional focus instructions to guide what it preserves
47
54
  - Usually lowest risk of deleting needed details
48
55
 
49
- ### `/dcp sweep`
50
-
51
- Use after a phase is complete to let DCP remove stale/noisy content automatically.
56
+ ### `codex resume`
52
57
 
53
- Good candidates for sweep-driven cleanup:
58
+ Resume a previous Codex session by thread ID:
54
59
 
55
- - wrong-target searches
56
- - failed dead-end exploration no longer needed
57
- - duplicate or superseded junk output
60
+ ```bash
61
+ codex resume
62
+ ```
58
63
 
59
- Do **not** sweep because output is merely "long". Length alone is not noise.
64
+ This restores the session transcript from `~/.codex/sessions/`. Useful for short interruptions where the full session context is still relevant.
60
65
 
61
66
  ## Session Lifecycle Protocol
62
67
 
63
68
  ### 1) Start Session
64
69
 
65
70
  1. Load task spec and essential policy docs only
66
- 2. Check context health (`/dcp context`)
67
- 3. Pull prior work only if needed:
68
- - `find_sessions({ query })`
69
- - `read_session({ session_id, focus })`
70
- - `memory-read({ file })` or `memory-search({ query })`
71
+ 2. Pull prior work only if needed:
72
+ - Read `.codex/context/session-context.md` for the last stop point
73
+ - Read `.codex/memory/project/state.md` for durable state
74
+ - Search repo memory: `bash .codex/scripts/memory_search.sh "query"`
75
+ - Use `codex resume` if continuing from the same thread
71
76
 
72
77
  ### 2) During Active Work
73
78
 
74
79
  - Keep active files readable until edits are done
75
- - At each natural boundary, evaluate compress candidates
76
- - Compress completed phases before starting the next chapter
80
+ - At each natural boundary, evaluate `/compact` candidates
81
+ - Persist durable findings to repo files before compacting
77
82
 
78
83
  ### 3) Pre-Handoff / Closeout
79
84
 
80
- 1. Compress completed phase ranges
81
- 2. Persist key decisions/learnings to memory (observation or memory-update)
82
- 3. Create concise handoff summary (what changed, what is pending, known risks)
85
+ 1. Run `/compact` on completed phase ranges
86
+ 2. Persist key decisions/learnings to durable repo files:
87
+ - `.codex/context/decision-log.md` for architecture decisions
88
+ - `.codex/context/worklog.md` for milestone trail
89
+ - `.codex/memory/project/state.md` for durable state
90
+ 3. Create concise handoff in `.codex/context/session-context.md`
83
91
 
84
92
  ### 4) Resume Session
85
93
 
86
- 1. Rehydrate only relevant context (dont replay everything)
94
+ 1. Rehydrate only relevant context (don't replay everything)
87
95
  2. Validate assumptions against current files/git state
88
96
  3. Continue with fresh context budget, not accumulated clutter
89
97
 
@@ -94,8 +102,8 @@ Use these thresholds as operational triggers:
94
102
  | Threshold | Interpretation | Required Action |
95
103
  | --- | --- | --- |
96
104
  | <50k | Healthy start | Keep inputs minimal, avoid unnecessary reads |
97
- | 50k100k | Moderate growth | Compress completed phases, keep active files intact |
98
- | >100k | High pressure | Aggressively compress by phase; run `/dcp sweep` on stale noise |
105
+ | 50k-100k | Moderate growth | `/compact` completed phases, keep active files intact |
106
+ | >100k | High pressure | Aggressively compact by phase; persist findings to repo files |
99
107
  | >150k | Near capacity | Perform handoff and resume in a fresh session |
100
108
 
101
109
  Secondary guardrails:
@@ -106,23 +114,25 @@ Secondary guardrails:
106
114
 
107
115
  ## Phase Boundary Triggers
108
116
 
109
- Compress at these boundaries:
117
+ Compact at these boundaries:
110
118
 
111
- - Research complete compress exploration + search outputs
112
- - Implementation wave complete compress completed read/edit/test cycles
113
- - Review complete compress raw reviewer outputs, keep synthesized findings
114
- - Before `/handoff` compress everything non-essential since last checkpoint
119
+ - Research complete -> persist findings to `memory/research/`, then `/compact`
120
+ - Implementation wave complete -> `/compact` completed read/edit/test cycles
121
+ - Review complete -> persist synthesized findings, `/compact` raw outputs
122
+ - Before `/handoff` -> compact everything non-essential since last checkpoint
115
123
 
116
- Rule: **Completed phases should not remain uncompressed for long.**
124
+ Rule: **Completed phases should not remain uncompacted for long.**
117
125
 
118
126
  ## Context Transfer Sources (Cross-Session)
119
127
 
120
128
  Use in priority order:
121
129
 
122
- 1. Memory artifacts (`memory-search`, `memory-read`, observations)
123
- 2. Session history (`find_sessions`, `read_session`)
124
- 3. Task tracker state (`br show <id>` when applicable)
125
- 4. Git evidence (`git diff`, `git log`, test output)
130
+ 1. Repo-visible files: `.codex/context/`, `.codex/memory/project/`, `.codex/memory/research/`
131
+ 2. Local retrieval: `bash .codex/scripts/memory_search.sh "query"`
132
+ 3. Codex session history: `codex resume` for thread-based recall
133
+ 4. Task tracker state: `br show <id>` when applicable
134
+ 5. Git evidence: `git diff`, `git log`, test output
135
+ 6. Optional MCP memory: only when repo docs are insufficient (requires MCP setup)
126
136
 
127
137
  Carry forward decisions and constraints, not every intermediate log.
128
138
 
@@ -130,31 +140,31 @@ Carry forward decisions and constraints, not every intermediate log.
130
140
 
131
141
  | Anti-Pattern | Why It Hurts | Correct Pattern |
132
142
  | --- | --- | --- |
133
- | Compressing active work areas (losing precision needed for edits) | Removes exact lines needed for safe edits | Keep active file/tool outputs until edit + verification complete |
134
- | Sweeping content you still need | Forces rework and increases error risk | Keep active files/tool outputs until phase is complete |
135
- | Not compressing completed exploration phases | Bloats context and degrades later turns | Compress immediately at phase completion |
136
- | Session handoff without persisting key decisions to memory | Next session loses rationale and constraints | Write observations/memory updates before handoff |
143
+ | Compacting active work areas | Removes exact lines needed for safe edits | Keep active file/tool outputs until edit + verification complete |
144
+ | Not compacting completed phases | Bloats context and degrades later turns | `/compact` immediately at phase completion |
145
+ | Session handoff without persisting to repo files | Next session loses rationale and constraints | Write to decision-log, state, worklog before handoff |
146
+ | Relying only on session memory for durable facts | Facts are lost when session ends | Persist to `.codex/context/` or `.codex/memory/` |
137
147
 
138
148
  ## Verification
139
149
 
140
- Check context health: are completed phases compressed? Are active files still readable?
150
+ Check context health: are completed phases compacted? Are active files still readable?
141
151
 
142
152
  Before claiming cleanup done, confirm:
143
153
 
144
154
  - Active edit targets are still present in readable form
145
- - Completed phases are compressed or intentionally kept for active work
146
- - No critical decision exists only in transient tool output
147
- - Handoff includes next actions and blockers
155
+ - Completed phases are compacted or intentionally kept for active work
156
+ - No critical decision exists only in transient session output
157
+ - Handoff includes next actions and blockers in repo-visible files
148
158
 
149
159
  ## Quick Playbook
150
160
 
151
161
  ```text
152
- 1) Start turn: /dcp context
162
+ 1) Start: read session-context.md + state.md
153
163
  2) Identify completed phase ranges
154
- 3) /dcp compress completed ranges
155
- 4) /dcp sweep stale/noisy outputs after phase completion
156
- 5) persist key decisions to memory
157
- 6) handoff/resume with focused rehydration
164
+ 3) Persist durable findings to repo files
165
+ 4) /compact completed ranges
166
+ 5) At session end: update session-context.md, state.md, worklog.md
167
+ 6) Resume: /prompts:resume or codex resume
158
168
  ```
159
169
 
160
170
  ## See Also
@@ -1,10 +1,17 @@
1
1
  ---
2
2
  name: session-management
3
- description: "Merged into context-management. Load that skill instead."
3
+ description: "Deprecated: merged into context-management. Load $context-management instead."
4
+ deprecated: true
4
5
  ---
5
6
 
6
- # Session Management
7
+ # Session Management (Deprecated)
7
8
 
8
- > This skill has been merged into `context-management` which now covers both context and session lifecycle management.
9
- >
10
- > Load `context-management` instead.
9
+ This skill has been merged into `$context-management` which now covers both context health and session lifecycle management.
10
+
11
+ **Load `$context-management` instead.**
12
+
13
+ The merged skill covers:
14
+ - Session start, pause, resume lifecycle
15
+ - Context budget thresholds and `/compact` usage
16
+ - Handoff/resume protocol with repo-visible files
17
+ - Cross-session context transfer strategies