Skip to content

Commit c04cfed

Browse files
josealekhineclaude
andcommitted
docs: add timestamp correlation guide to AGENT_PLAYBOOK
Document how agents can correlate context entries (tasks, learnings, decisions) to sessions using timestamps: - Timestamp format: YYYY-MM-DD-HHMM (consistent across all entry types) - Session time bounds: start_time and end_time fields - Correlation method: Check if entry timestamp falls within session bounds - Use cases: Tracing decisions, understanding context, debugging Updated both the project's AGENT_PLAYBOOK.md and the template. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 97e0e68 commit c04cfed

3 files changed

Lines changed: 69 additions & 1 deletion

File tree

.context/AGENT_PLAYBOOK.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,47 @@ These are updated throughout the session.
6060

6161
See `.claude/hooks/auto-save-session.sh` for the implementation.
6262

63+
## Timestamp-Based Session Correlation
64+
65+
Context entries (tasks, learnings, decisions) include timestamps that allow
66+
you to determine which session created them.
67+
68+
### Timestamp Format
69+
70+
All timestamps use `YYYY-MM-DD-HHMM` format:
71+
- **Tasks**: `- [ ] Do something #added:2026-01-23-1430`
72+
- **Learnings**: `- **[2026-01-23-1430]** Discovered that...`
73+
- **Decisions**: `## [2026-01-23-1430] Use PostgreSQL`
74+
- **Sessions**: `**start_time**: 2026-01-23-1400` / `**end_time**: 2026-01-23-1530`
75+
76+
### Correlating Entries to Sessions
77+
78+
To find which session added an entry:
79+
80+
1. **Extract the entry's timestamp** (e.g., `2026-01-23-1430`)
81+
2. **List sessions** from that day: `ls .context/sessions/2026-01-23*`
82+
3. **Check session time bounds**:
83+
```bash
84+
grep -l "start_time.*2026-01-23-14" .context/sessions/*.md
85+
```
86+
4. **Match**: Entry timestamp should fall between session's start_time and end_time
87+
88+
### Example
89+
90+
Given a learning with timestamp `2026-01-23-1430`:
91+
```
92+
Session A: start_time: 2026-01-23-1000, end_time: 2026-01-23-1200 # Too early
93+
Session B: start_time: 2026-01-23-1400, end_time: 2026-01-23-1530 # ✓ Contains 1430
94+
Session C: start_time: 2026-01-23-1600, end_time: 2026-01-23-1800 # Too late
95+
```
96+
→ The learning was added during Session B.
97+
98+
### When Timestamps Help
99+
100+
- **Tracing decisions**: "Why did we decide X?" → Find the session that added it
101+
- **Understanding context**: Read the full session for the discussion that led to an entry
102+
- **Debugging issues**: Correlate when a learning was discovered with what was happening
103+
63104
## Session File Structure (Suggested)
64105

65106
Adapt this structure based on session type.

.context/TASKS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
- [x] Increase timestamp precision in formatDecision() — change from YYYY-MM-DD to YYYY-MM-DD-HHMM
137137
- [x] Add start_time field to session summary files — record when session began
138138
- [-] Add last_update_time field to session summary files — skipped: end_time provides session bounds; tracking live updates requires state persistence
139-
- [ ] Document timestamp correlation approach in AGENT_PLAYBOOK.md — explain how to correlate entries to sessions by time overlap
139+
- [x] Document timestamp correlation approach in AGENT_PLAYBOOK.md — explain how to correlate entries to sessions by time overlap
140140

141141
### Phase 13: Rich Context Entries `#priority:medium` `#area:cli`
142142
- [ ] Add --file flag to ctx add — read entry content from a file instead of CLI arg

internal/templates/AGENT_PLAYBOOK.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,33 @@ ls .context/sessions/
5656

5757
See `.claude/hooks/auto-save-session.sh` for the implementation.
5858

59+
## Timestamp-Based Session Correlation
60+
61+
Context entries (tasks, learnings, decisions) include timestamps that allow
62+
you to determine which session created them.
63+
64+
### Timestamp Format
65+
66+
All timestamps use `YYYY-MM-DD-HHMM` format:
67+
- **Tasks**: `- [ ] Do something #added:2026-01-23-1430`
68+
- **Learnings**: `- **[2026-01-23-1430]** Discovered that...`
69+
- **Decisions**: `## [2026-01-23-1430] Use PostgreSQL`
70+
- **Sessions**: `**start_time**: 2026-01-23-1400` / `**end_time**: 2026-01-23-1530`
71+
72+
### Correlating Entries to Sessions
73+
74+
To find which session added an entry:
75+
76+
1. **Extract the entry's timestamp** (e.g., `2026-01-23-1430`)
77+
2. **List sessions** from that day: `ls .context/sessions/2026-01-23*`
78+
3. **Check session time bounds**: Entry timestamp should fall between session's start_time and end_time
79+
80+
### When Timestamps Help
81+
82+
- **Tracing decisions**: "Why did we decide X?" → Find the session that added it
83+
- **Understanding context**: Read the full session for the discussion that led to an entry
84+
- **Debugging issues**: Correlate when a learning was discovered with what was happening
85+
5986
## Session File Structure (Suggested)
6087

6188
Adapt this structure based on session type. Not all sections are needed for every session.

0 commit comments

Comments
 (0)