aboutsummaryrefslogtreecommitdiff
path: root/docs/protocols.org
blob: b3106b6c204c517faf40f8c4439bc56613f70913 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
#+TITLE: Claude Code Protocols
#+AUTHOR: Craig Jennings & Claude
#+DATE: 2025-11-05

* About This File

This file contains instructions and protocols for how Claude should behave when working with Craig. These protocols are consistent across all projects.

**When to read this:**
- At the start of EVERY session (this is the single entry point)
- Before making any significant decisions
- When unclear about user preferences or conventions

**What's in this file:**
- Directory architecture (docs/ file/directory map)
- Session management protocols (context files, compacting)
- Terminology and trigger phrases
- User information and preferences
- Git commit requirements
- File format and naming conventions
- Startup instructions (runs docs/workflows/startup.org)

**What's NOT in this file:**
- Project-specific context (see notes.org)
- Session history (see notes.org)
- Active reminders (see notes.org)
- Pending decisions (see notes.org)

* Directory Architecture

The =docs/= directory has a specific structure. Every file and directory has a defined purpose:

| Item | Purpose |
|------+---------|
| =protocols.org= | Single entry point — behavioral instructions + directory map |
| =notes.org= | Project data: context, reminders, decisions, session history |
| =session-context.org= | Live crash recovery (exists only during active sessions) |
| =previous-session-history.org= | Archived session history |
| =workflows/= | Template workflows (synced from claude-templates, never edit in project) |
| =project-workflows/= | Project-specific workflows (never touched by sync) |
| =scripts/= | Template scripts |
| =announcements/= | One-off cross-project instructions from Craig |
| =someday-maybe.org= | Project ideas backlog |

* IMPORTANT - MUST DO

** CRITICAL: Always Check the Time with =date= Command

***NEVER GUESS THE TIME. ALWAYS RUN =date= TO CHECK.***

Claude's internal sense of time is unreliable. When mentioning what time it is - whether in conversation, session notes, timestamps, or scheduling - ALWAYS run:

#+begin_src bash
date "+%A %Y-%m-%d %H:%M %Z"
#+end_src

This applies to:
- "What time is it?"
- Session start/end timestamps
- Calculating time until appointments
- Setting alarms
- Any time-related statement

Do NOT estimate, guess, or rely on memory. Just run the command. It takes one second and prevents errors.

** !!!!! SESSION CONTEXT FILE - READ THIS EVERY TIME !!!!!

#+begin_example
╔══════════════════════════════════════════════════════════════════════════════╗
║  STOP. THIS IS THE MOST IMPORTANT PROTOCOL IN THIS ENTIRE FILE.              ║
║                                                                              ║
║  UPDATE docs/session-context.org EVERY 3RD RESPONSE.                         ║
║                                                                              ║
║  NOT "when convenient." NOT "when there's a lot to write." EVERY 3RD ONE.    ║
║  Count: 1, 2, 3, UPDATE. 1, 2, 3, UPDATE. 1, 2, 3, UPDATE.                   ║
║                                                                              ║
║  FAILURE TO DO THIS HAS ALREADY CAUSED LOST WORK. DON'T LET IT HAPPEN AGAIN. ║
╚══════════════════════════════════════════════════════════════════════════════╝
#+end_example

*** Why This Is Here In Giant Letters

On 2026-01-22, a session crashed and 20+ minutes of detailed workflow planning was lost because the session context file wasn't updated. The information was gone forever. This protocol exists to prevent that from EVER happening again.

*** Location
=docs/session-context.org= (always this exact path, every project)

*** UPDATE FREQUENCY: EVERY. 3RD. RESPONSE.

This means:
- Craig says something, you respond (1)
- Craig says something, you respond (2)
- Craig says something, you respond (3) → **UPDATE THE FILE NOW**
- Repeat: 1, 2, 3 → UPDATE

"Response" = one Claude response. After THREE of these, update the file. No exceptions.

*** What Counts as "Updating"

Actually write to the file using the Edit or Write tool. Not "I should update it." Not "I'll update it soon." ACTUALLY WRITE TO THE FILE.

Include:
- Current task/goal being worked on
- Key decisions made this session
- Workflows being designed (capture the FULL details)
- Data collected (vitals, measurements, paths, commands, etc.)
- Files modified or created
- Next steps planned
- ANY context needed to resume if session crashes RIGHT NOW

*** Why This Is Non-Negotiable

If the machine freezes, the network drops, or Claude crashes:
- Session history in notes.org? NOT WRITTEN YET (only at wrap-up)
- Your memory of the conversation? GONE
- The ONLY way to recover context? THIS FILE

If you don't update it, the work is LOST. Period. There is no recovery.

*** At Session Start - CHECK FOR THIS FILE
If =docs/session-context.org= exists when starting a new session, it means the previous session was interrupted. Read it IMMEDIATELY to recover context.

** Before Compacting
If you know you're about to compact, update the session context file FIRST, with enough detail that you can pick up the discussion without having lost any essential information.

** After Compacting
Review the session context file to make sure you aren't forgetting key aspects of our discussion or plan, then continue working with the user.

** When Session Ends (Wrap-Up Workflow)
Write your session summary to notes.org, leveraging the session context file. Delete session-context.org ONLY AFTER you've written the session history entry. The file's existence indicates an interrupted session, so it must be deleted at the end of each successful wrap-up.

** NEVER =cd= Into Directories You Will Delete

If you =cd= into a directory and then delete that directory, the shell's working directory becomes invalid. All subsequent commands will fail silently (exit code 1) with no useful error message. The only fix is to restart the session.

***Rule:*** Always use absolute paths for file operations in temporary directories. Never =cd= into extraction directories, build directories, or any directory that will be cleaned up.

This caused a session break on 2026-02-06 when an extraction directory was =cd='d into and then deleted during cleanup.

* Important Terminology

** "Let's run the [X] workflow" vs "I want to create an [X] workflow"

These phrases mean DIFFERENT things!

*** "Let's run/do the [workflow name] workflow"
This means: **Execute the existing workflow** for that process.

*Example:*
- "Let's run the refactor workflow" -> Read docs/workflows/refactor.org and guide through workflow
- "Let's do a refactor workflow" -> Same as above

*** "I want to create an [X] workflow"
This means: **CREATE a new workflow definition** for doing X (meta-work).
This does **NOT** mean "let's DO X right now."

*Example:*
- "I want to create a refactor workflow" -> Create docs/workflows/refactor.org using create-workflow process

When Craig uses this phrasing, trigger the create-workflow process from docs/workflows/create-workflow.org. New workflows go to =docs/project-workflows/= by default. Only put a workflow in =docs/workflows/= (and =~/projects/claude-templates/docs/workflows/=) if Craig explicitly says it's for all projects.

** "Wrap it up" / "That's a wrap" / "Let's call it a wrap"

Execute the wrap-up workflow (details in Session Protocols section below):
1. Write session notes to notes.org
2. Git commit and push all changes
3. Valediction summary

* User Information

** Calendar Location
Craig's calendars are at: =~/.emacs.d/data/*cal.org= (gcal.org, dcal.org, pcal.org)

These files are **READ-ONLY** — NEVER add anything to them.

Use this to:
- Check meeting times and schedules
- Verify when events occurred
- See what's upcoming

If there are tasks or events to schedule, put them in the todo.org file in the project root, not in Craig's calendar.

** Task List Location
Craig's global task list is available at: =/home/cjennings/sync/org/roam/inbox.org=

Use this to:
- See all the tasks that he's working on outside of projects like this one

**Note:** Some projects may have a project-specific task file (e.g., =todo.org= at project root). Check notes.org for project-specific task locations.

** Working Style

*** General Preferences
- Prefers detailed preparation before high-stakes meetings
- Values practice/role-play for negotiations and general learning
- Makes decisions based on principles and timeline arguments
- Prefers written documentation over verbal agreements

*** Emacs as a Primary Working Tool
- Craig uses Emacs as his primary tool (most everything Craig does is inside Emacs)
- Consider Emacs packages along with other software when recommending software solutions
- Look for ways to streamline routine work with Emacs custom code if no packages exist

*** Wayland Environment (No XWayland)
Craig runs a pure Wayland setup (Hyprland) and avoids XWayland/Xorg apps.

- Clipboard: Use =wl-copy= and =wl-paste= (NOT =xclip= or =xsel=)
- Window management: Use Hyprland commands (NOT =xkill=, =xdotool=, etc.)
- Prefer Wayland-native tools over X11 equivalents
- Open URLs in browser: Use =google-chrome-stable "URL" &>/dev/null &=
  - The =&>/dev/null &= is required to detach the process and suppress output
  - Without it, the command may appear to hang or produce no result

** Miscellaneous Information
- Craig currently lives in New Orleans, LA
- Craig's phone number: 510-316-9357
- Craig maintains a remote server at the cjennings.net domain
- This project is in a git repository which is associated with a remote repository on cjennings.net

** Setting Alarms / Reminders

Use Craig's =notify= script with the =at= daemon for persistent reminders.

**IMPORTANT:** Always check the current date and time (=date=) before setting alarms to ensure accurate calculations.

*** Setting an alarm
#+begin_src bash
echo 'notify alarm "Title" "Message"' | at 10:55am
#+end_src

*** Examples
#+begin_example
echo 'notify alarm "Standup" "Daily standup in 5 minutes"' | at 10:55am
echo 'notify alarm "BP Reading" "Time to take BP"' | at 2:00pm
echo 'notify alert "Meeting" "Ryan call starting"' | at 11:25am
#+end_example

*** Notify types available
- =alarm= - Alarm clock icon, alarm sound
- =alert= - Yellow exclamation, attention tone
- =info= - Blue info icon, confident tone
- =success= - Green checkmark, pleasant chime
- =fail= - Red X, warning tone

Full usage: =notify --help= or see =~/.local/bin/notify=

*** Managing alarms
- =atq= - list all scheduled alarms
- =atrm [number]= - remove an alarm by its queue number

* Session Protocols

** CRITICAL: Git Commit Requirements

***IMPORTANT: ALL commits must be made as Craig, NOT as Claude.***

***CRITICAL: NO Claude Code or Anthropic attribution ANYWHERE in commits.***

When creating commits:

1. **Author Identity**: NEVER commit as Claude. All commits must use Craig's identity.
   - Git will use the configured user.name and user.email
   - Do NOT modify git config
   - **ABSOLUTELY NO** Co-Authored-By lines
   - **ABSOLUTELY NO** "Generated with Claude Code" text
   - **ABSOLUTELY NO** Anthropic attribution of any kind
   - Write commits AS CRAIG, not as Claude Code

2. **Commit Message Format**:
   - Use project-specific commit format if defined
   - Otherwise: concise subject line and terse description only
   - **ONLY subject line and terse description - NO Claude Code attribution**
   - Keep messages clear and informative

3. **Validation**:
   - Claude should validate commit message format before committing
   - Ensure no AI attribution appears anywhere in commit

** IMPORTANT: Reminders Protocol

When starting a new session:
- Check "Active Reminders" section in notes.org
- Remind Craig of outstanding tasks he's asked to be reminded about
- This ensures important follow-up actions aren't forgotten between sessions

When Craig says "remind me" about something:
1. Add it to Active Reminders section in notes.org
2. If it's something he needs to DO, also add to the todo.org file in the project root as an org-mode task (e.g., =* TODO [description]=). If this project does not have a todo.org at the project root, alert Craig and offer to create it.
3. If not already provided, ask for the priority and a date for scheduled or deadline.

** Workflows: "Let's run/do the [workflow name] workflow"

When Craig says this phrase:

1. **Check =docs/workflows/= for match**
   - If exact match found: Read and guide through process
   - Example: "refactor workflow" -> read docs/workflows/refactor.org

2. **Check =docs/project-workflows/= for match**
   - If exact match found: Read and guide through process

3. **Fuzzy match across both directories:** Ask for clarification
   - Example: User says "empty inbox" but we have "inbox-zero.org"
   - Ask: "Did you mean the 'inbox zero' workflow, or create new 'empty inbox'?"

4. **No match at all:** Offer to create it
   - Say: "I don't see '[workflow-name]' yet. Create it using create-workflow process?"
   - If yes: Run create-workflow — new workflows go to =docs/project-workflows/= by default

** Long-Running Process Status Updates

When monitoring a long-running process (rsync, large downloads, builds, VM tests, etc.), follow this protocol:

***At Start:***
1. Run =date= to get accurate time
2. Announce the task/job beginning
3. Provide best-guess ETA for completion

#+begin_example
**14:30** - Starting ISO build. ETA: ~10 minutes.
#+end_example

***Every 5 Minutes:***
- Check progress and display status in format: =HH:MM= - terse description - ETA

#+begin_example
**14:35** - ISO build: packages installed, creating squashfs. ETA: ~5 min.
**14:40** - ISO build: squashfs 95% complete. ETA: ~1 min.
#+end_example

***At Completion:***
1. Send notification via notify script:
   #+begin_src bash
   notify success "Task Complete" "Description of what finished"
   #+end_src
   Use =fail= type instead of =success= if the task failed.
2. Provide summary of success or failure

#+begin_example
**14:42** - ISO build complete. Size: 2.0G. Ready for testing.
#+end_example

***Guidelines:***
- Always run =date= for accurate timestamps
- Keep progress descriptions terse but informative
- Update ETA as job progresses
- If ETA cannot be determined, say "ETA unknown" rather than guessing wildly

***Why This Matters:***
- Craig may be working on other things while waiting
- Status updates provide confidence the process is still running
- ETAs help with planning (e.g., "I have time for coffee" vs "stay close")
- Sound notification alerts Craig when he's away from the screen
- If something stalls, the updates make it obvious

** "Wrap it up" / "That's a wrap" / "Let's call it a wrap"

When Craig says any of these phrases (or variations), execute wrap-up workflow:

1. **Write session notes** to notes.org (Session History section)
   - Key decisions made
   - Work completed
   - Context needed for next session
   - Any pending issues or blockers
   - New conventions or preferences learned
   - Critical reminders for tomorrow go in Active Reminders section

2. **Git commit and push** (if project is in git repository)
   - Check git status and diff
   - Create commit message following requirements (see "Git Commit Requirements" above)
   - **ONLY subject line and terse description - NO Claude Code attribution**
   - Commit as Craig (NOT as Claude)
   - **ABSOLUTELY NO** Co-Authored-By, Claude Code, or Anthropic attribution
   - Push to ALL remotes (check with =git remote -v=)
   - Ensure working tree is clean
   - Confirm push succeeded to all remotes

3. **Valediction** - Brief, warm goodbye
   - Acknowledge the day's work
   - What was accomplished
   - What's ready for next session
   - Any important reminders
   - Keep it warm but concise

This ensures clean handoff between sessions and nothing gets lost.

** The docs/ Directory

Claude needs to add information to notes.org. For large amounts of information:

- Create separate document in docs/ directory
- Link it in notes.org with explanation of document's purpose
- **Project-specific decision:** Should docs/ be committed to git or added to .gitignore?
  - Ask Craig on first session if not specified
  - Some projects keep docs/ private, others commit it
- Unless specified otherwise, all Claude-generated documents go in docs/ folder

**When to break out documents:**
- If notes.org gets very large (> 1500 lines)
- If information isn't all relevant anymore
- Example: Keep only last 3-4 months of session history here, move rest to separate file

* File Format Preferences

** ALWAYS Use Org-Mode Format

Craig uses Emacs as primary tool. **ALWAYS** create new documentation files in =.org= format, not =.md= (markdown).

*Rationale:*
- Org-mode files are well-supported in Emacs
- Can be easily exported to any other format (HTML, PDF, Markdown, etc.)
- Better integration with user's workflow

*Exception:* Only use .md if specifically requested or if file is intended for GitHub/web display where markdown is expected.

** NEVER Use Spaces in Filenames

**ALWAYS** use hyphens (=-=) to separate words in filenames. Underscores (=_=) are also acceptable.

*Rationale:*
- Spaces cause problems with links across different operating systems
- User works with Mac, Windows, Linux, and potentially other systems
- Hyphens create more reliable, portable filenames
- Easier to work with in command-line tools

*Examples:*
- Good: =project-meeting-notes.org=
- Good: =change-log-2025-11-04.md=
- Bad: =project meeting notes.org=
- Bad: =change log 2025.11.04.md=

* File Naming Conventions

** Files Too Large to Read

PDFs or other files that are too large for Claude to read should be prefixed with =TOOLARGE-= to prevent read errors that halt the session.

Example:
- Original: =assets/large-architectural-plans.pdf=
- Renamed: =assets/TOOLARGE-large-architectural-plans.pdf=

** Unreadable Binary Files (.docx Format)

Binary .docx files cannot be read directly by Claude. When encountering these:
- Convert to markdown format using pandoc: =pandoc file.docx -o file.md=
- Keep the original .docx file for reference
- Work with the converted .md file for analysis and editing

** CRITICAL: Always Keep Links Current

Many documents are linked in org files using org-mode =file:= links. Craig relies on these links being valid at all times.

**MANDATORY WORKFLOW - When renaming or moving ANY file:**

1. **BEFORE renaming:** Search ALL org files for references to that file
   - Use grep or search tools to find both filename and partial matches
   - Check in TODO items and event log sections

2. **Rename or move the file**

3. **IMMEDIATELY AFTER:** Update ALL =file:= links to new path/filename
   - Update links in task files
   - Update links in event logs
   - Update links in reference sections

4. **Verify:** Test a few updated links to ensure they point to valid files

Example workflow:
#+begin_example
# Step 1: Search before renaming
grep -rn "2025-10-15-invoice.pdf" *.org

# Step 2: Rename the file
mv documents/2025-10-15-invoice.pdf documents/2025-10-15-vendor-invoice.pdf

# Step 3: Update all references in affected .org files
# Edit to change:
#   file:documents/2025-10-15-invoice.pdf
# to:
#   file:documents/2025-10-15-vendor-invoice.pdf

# Step 4: Verify links work
#+end_example

*Why This is Critical:*
- Org files are primary task tracking and reference system
- Event logs document complete history with file references
- Craig depends on clicking links to access documents quickly
- Broken links disrupt workflow and make documentation unreliable

**NEVER rename or move files without updating links in the same session.**

* Session Start - AUTOMATIC

At the start of EVERY session, run [[file:workflows/startup.org][docs/workflows/startup.org]]. Do NOT ask — just do it automatically.