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
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
|
# AI Agent Guidelines for ngit-grasp
**Purpose:** Ensure AI agents (and humans) maintain consistent documentation practices and avoid common pitfalls.
**Last Updated:** November 4, 2025
---
## π Documentation Structure
### Overview
We use the **[DiΓ‘taxis](https://diataxis.fr/) framework** for all documentation. This prevents documentation sprawl by organizing content into four clear categories based on purpose and audience.
```
ngit-grasp/
βββ README.md # Project overview (keep updated)
βββ AGENTS.md # This file - agent guidelines
βββ CHANGELOG.md # User-facing changes (semver)
β
βββ work/ # Temporary session files (.gitignore'd)
β βββ README.md # Only file committed to git
β βββ *.md # Session notes, status, plans (temporary)
β
βββ docs/ # All documentation (DiΓ‘taxis structure)
β βββ README.md # Navigation guide with quadrant diagram
β β
β βββ tutorials/ # Learning-oriented (practical + learning)
β β βββ getting-started.md # First-time setup
β β βββ first-audit.md # Running your first audit
β β
β βββ how-to/ # Task-oriented (practical + working)
β β βββ deploy.md # Production deployment
β β βββ nix-flakes.md # Nix environment setup
β β βββ test-compliance.md # Running compliance tests
β β βββ upgrade-nostr-sdk.md # SDK upgrade guide
β β
β βββ reference/ # Information-oriented (theoretical + working)
β β βββ git-protocol.md # Git Smart HTTP protocol
β β βββ grasp-protocol.md # GRASP specification
β β βββ configuration.md # All config options
β β βββ test-strategy.md # Testing reference
β β βββ api.md # Internal API docs
β β
β βββ explanation/ # Understanding-oriented (theoretical + learning)
β β βββ architecture.md # System design overview
β β βββ inline-authorization.md # Why inline auth?
β β βββ comparison.md # vs ngit-relay
β β βββ decisions.md # Design decisions
β β
β βββ archive/ # Historical session notes
β β βββ YYYY-MM-DD-*.md # Completed work
β β
β βββ learnings/ # DEPRECATED - migrated to DiΓ‘taxis
β βββ README.md # Migration notice
β
βββ grasp-audit/ # Audit tool subproject
β βββ README.md # Main audit docs
β βββ docs/ # Follows same DiΓ‘taxis structure
β βββ tutorials/
β βββ how-to/
β βββ reference/
β βββ explanation/
β
βββ .ai/ # AI assistant context (ignored in git)
βββ history/ # Conversation history
```
### DiΓ‘taxis Framework
All documentation MUST fit into one of four categories:
**π Tutorials** (`docs/tutorials/`)
- **Purpose:** Learning-oriented, teach by doing
- **Audience:** Newcomers, beginners
- **Style:** Step-by-step lessons with guaranteed outcomes
- **Examples:** Getting Started, First Audit
- **Question:** "Can you teach me to...?"
**π§ How-To Guides** (`docs/how-to/`)
- **Purpose:** Task-oriented, solve problems
- **Audience:** Users with basic knowledge
- **Style:** Practical recipes and solutions
- **Examples:** Deploy, Configure, Troubleshoot
- **Question:** "How do I...?"
**π Reference** (`docs/reference/`)
- **Purpose:** Information-oriented, technical facts
- **Audience:** Users looking up specific information
- **Style:** Dry, factual, comprehensive
- **Examples:** API docs, Config options, Protocols
- **Question:** "What is...?"
**π‘ Explanation** (`docs/explanation/`)
- **Purpose:** Understanding-oriented, clarify concepts
- **Audience:** Users wanting deeper understanding
- **Style:** Discussion, context, alternatives
- **Examples:** Architecture, Design Decisions, Comparisons
- **Question:** "Why...?"
**See:** [DiΓ‘taxis documentation](https://diataxis.fr/) for detailed guidance.
### File Type Guidelines
**Markdown (.md):**
- Primary format for all documentation
- Easy to read in plain text and rendered
- Supports code blocks, links, tables
- Version control friendly
**Text (.txt):**
- Only for visual ASCII art summaries
- Must be archived after session (never permanent)
- Examples: status boxes, visual diagrams
- Archive to `docs/archive/YYYY-MM-DD-name.txt`
**Other formats:**
- Avoid unless absolutely necessary
- If needed, document in README.md why
---
## π Document Lifecycle
### 1. Working Documents (work/ Directory)
**Purpose:** Session-specific temporary files
**Location:** `work/` directory (.gitignore'd)
**Lifecycle:** Created β Used β Archived or Deleted
**Retention:** Archive valuable content, delete rest at session end
**Examples:**
- `work/session-notes.md` β Session notes and progress
- `work/status.md` β Current status report
- `work/migration-plan.md` β Planning document
- `work/visual-summary.txt` β ASCII art summaries
**Rules:**
- β
Create ALL session-specific docs in `work/`
- β
Use descriptive names (no date prefix needed)
- β
Archive valuable content to `docs/archive/YYYY-MM-DD-name.md`
- β
Delete obsolete files at session end
- β
Keep `work/` clean (empty except README.md when not in session)
- β Don't commit `work/` contents to git (except README.md)
- β Don't reference `work/` docs from permanent documentation
- β Don't let `work/` accumulate files between sessions
**Why work/ instead of root:**
- Keeps root clean (only README.md, AGENTS.md, CHANGELOG.md)
- Clear separation: permanent vs. temporary
- Not committed to git (reduces noise)
- Easy to clean up (just `rm -rf work/*`)
### 2. Permanent Documentation (docs/)
**Purpose:** Long-term reference, architecture, guides
**Location:** `docs/` (organized by DiΓ‘taxis category)
**Lifecycle:** Created β Maintained β Updated
**Retention:** Permanent (version controlled)
**Structure:**
- `docs/tutorials/` - Learning-oriented lessons
- `docs/how-to/` - Task-oriented guides
- `docs/reference/` - Information-oriented facts
- `docs/explanation/` - Understanding-oriented discussion
**Examples:**
- `docs/tutorials/getting-started.md` - First-time setup
- `docs/how-to/deploy.md` - Deployment guide
- `docs/reference/configuration.md` - Config options
- `docs/explanation/architecture.md` - System design
**Rules:**
- β
Categorize by DiΓ‘taxis framework (tutorial/how-to/reference/explanation)
- β
Keep updated as project evolves
- β
Use clear structure and headings
- β
Link between related docs
- β Don't duplicate information (use links)
- β Don't include session-specific details
- β Don't put docs in wrong category (see DiΓ‘taxis guide)
### 3. Archive (docs/archive/)
**Purpose:** Historical record, completed phases
**Location:** `docs/archive/`
**Lifecycle:** Moved from root β Archived
**Retention:** Permanent (for reference)
**Examples:**
- `docs/archive/2025-11-04-tag-migration.md`
- `docs/archive/2025-11-03-architecture-investigation.md`
**Rules:**
- β
Rename with date prefix when archiving
- β
Add "ARCHIVED" marker at top
- β
Extract learnings to docs/learnings/ first
- β Don't modify after archiving
- β Don't reference in active documentation
### 4. Learnings (DEPRECATED)
**Status:** `docs/learnings/` is deprecated - content migrated to DiΓ‘taxis structure
**Migration:**
- Gotchas and patterns β `docs/how-to/`
- Technical details β `docs/reference/`
- Understanding concepts β `docs/explanation/`
**Examples:**
- `learnings/nix-flakes.md` β `how-to/nix-flakes.md`
- `learnings/nostr-sdk.md` β `reference/nostr-sdk-upgrade.md`
- `learnings/git-http-backend.md` β `reference/git-protocol.md`
**Rules:**
- β Don't create new files in `docs/learnings/`
- β
Migrate existing content to appropriate DiΓ‘taxis category
- β
Add redirect notice in old location
---
## π Cleanup Process
### When to Clean Up
**Trigger:** End of session OR `work/` has >5 files
**Frequency:** End of each session (mandatory)
**Responsibility:** AI agents should proactively clean up before session end
### Cleanup Steps
1. **Review work/ Directory**
```bash
# List all working docs
ls -la work/
```
2. **Extract to DiΓ‘taxis Categories**
- Review each doc in `work/`
- Extract valuable content to appropriate category:
- Gotchas/solutions β `docs/how-to/`
- Technical facts β `docs/reference/`
- Concepts/design β `docs/explanation/`
- Lessons β `docs/tutorials/`
3. **Archive Important Session Docs**
```bash
# Archive valuable session docs with date prefix
mv work/migration-complete.md docs/archive/2025-11-04-migration-complete.md
mv work/visual-summary.txt docs/archive/2025-11-04-visual-summary.txt
```
4. **Delete Temporary Files**
```bash
# Delete obsolete working docs
rm work/status.md
rm work/notes.md
# Or clean everything
rm -rf work/*
# (work/README.md is safe - in .gitignore exception)
```
5. **Verify Clean State**
```bash
# Root should only have these:
ls *.md
# README.md
# AGENTS.md
# (CHANGELOG.md when created)
# work/ should be empty (except README.md)
ls work/
# README.md
```
6. **Commit Changes**
- Commit new permanent docs
- Commit archived docs
- Note: work/ contents not committed (gitignored)
### Example Cleanup
```bash
# Before cleanup (messy root!)
ls *.md
# README.md
# AGENTS.md
# CURRENT_STATUS.md
# DIATAXIS_MIGRATION.md
# SUMMARY.md
# SESSION_NOTES.md
# ... (many more)
# After cleanup (clean root!)
ls *.md
# README.md
# AGENTS.md
# Working files in work/ during session
ls work/
# README.md
# session-notes.md
# status.md
# After session cleanup
ls work/
# README.md
# (all session files archived or deleted)
# Archived
ls docs/archive/ | tail -5
# 2025-11-04-diataxis-migration.md
# 2025-11-04-diataxis-complete.md
# 2025-11-04-diataxis-migration-visual.txt
# 2025-11-04-session-summary.md
# ...
# Permanent docs in DiΓ‘taxis structure
ls docs/tutorials/
# getting-started.md
# first-audit.md
ls docs/how-to/
# nix-flakes.md
# deploy.md
```
---
## π¨ Common Gotchas
### Nix Flakes
**Always use `nix develop`, not `nix-shell`**
```bash
# β
Correct
cd grasp-audit
nix develop
nix develop -c cargo build
# β Wrong
nix-shell
nix-shell --run "cargo build"
```
**Why:** We use `flake.nix`, not `shell.nix`. See `docs/learnings/nix-flakes.md`.
**Flake Commands:**
```bash
# Show flake outputs
nix flake show
# Update flake inputs
nix flake update
# Build package
nix build
# Run package
nix run
```
### Git Subprojects
**grasp-audit is a subproject with its own flake**
```bash
# β
Correct - enter grasp-audit environment
cd grasp-audit
nix develop
cargo build
# β Wrong - can't build from root
cd ngit-grasp
cargo build # This won't find grasp-audit
```
**Why:** `grasp-audit/` has its own `Cargo.toml` and `flake.nix`.
### nostr-sdk Versions
**We use nostr-sdk 0.43.x (latest stable)**
```toml
# β
Correct
[dependencies]
nostr-sdk = "0.43"
# β Wrong
nostr-sdk = "0.35" # Old version, breaking changes
```
**Why:** We upgraded from 0.35 to 0.43. See `docs/learnings/nostr-sdk.md` for migration notes.
**Common Breaking Changes:**
- `EventBuilder::new()` signature changed
- Tag API changed to `Tag::custom()`
- Filter API changed
- See archived upgrade docs for details
### Testing Patterns
**Integration tests require relay**
```bash
# β
Correct - start relay first
docker run --rm -p 7000:7000 scsibug/nostr-rs-relay
# Then run tests
cd grasp-audit
nix develop -c cargo test --ignored
# β Wrong - integration tests will fail
cargo test --ignored # No relay running
```
**Test Organization:**
```rust
// Unit tests (no relay needed)
#[cfg(test)]
mod tests {
#[test]
fn test_something() { }
}
// Integration tests (relay required)
#[cfg(test)]
mod tests {
#[test]
#[ignore] // Requires relay
fn test_against_relay() { }
}
```
### Documentation Updates
**Keep README.md synchronized**
When you:
- Complete a major feature β Update README.md status
- Change architecture β Update docs/ARCHITECTURE.md
- Add dependencies β Update README.md tech stack
- Change workflow β Update docs/GETTING_STARTED.md
**Don't:**
- Create duplicate documentation
- Leave stale status markers
- Forget to update CHANGELOG.md for user-facing changes
---
## π File Format Guidelines
### When to Use .txt Files
**Use .txt ONLY for:**
- ASCII art visual summaries
- Box diagrams with Unicode characters
- Terminal-style status displays
**Examples of appropriate .txt content:**
```
ββββββββββββββββββββββββββββββββββββββββββ
β STATUS: β
COMPLETE β
ββββββββββββββββββββββββββββββββββββββββββ
```
**Rules:**
- β
Create in root during session for visual impact
- β
Archive immediately after session ends
- β
Use descriptive names: `CLEANUP_VISUAL_SUMMARY.txt`
- β Never keep .txt files in root long-term
- β Don't use .txt for regular documentation
- β Don't duplicate information (use .md instead)
**Lifecycle:**
```
Create .txt β Use in session β Archive immediately
```
### When to Use .md Files
**Use .md for ALL documentation:**
- Architecture docs
- Session summaries
- Status reports
- Learnings
- Planning documents
- API documentation
- User guides
**Why markdown is preferred:**
- Renders nicely on GitHub/GitLab
- Supports code blocks with syntax highlighting
- Easy to link between documents
- Better for long-form content
- Version control friendly
---
## π Writing Guidelines
### Markdown Style
```markdown
# Title (H1 - only one per file)
**Date:** YYYY-MM-DD
**Status:** [WIP|COMPLETE|ARCHIVED]
## Section (H2)
### Subsection (H3)
**Bold** for emphasis, `code` for commands/code.
- Bullet lists for items
- Keep consistent style
1. Numbered lists for sequences
2. Use when order matters
β
Use emoji for status (sparingly)
β Don't overuse emoji
\`\`\`bash
# Code blocks with language
cargo build
\`\`\`
```
### Status Markers
- `[WIP]` - Work in progress
- `[COMPLETE]` - Finished, may be archived
- `[ARCHIVED]` - Moved to archive, historical only
- `β
` - Success/complete
- `β` - Failure/incorrect
- `β³` - In progress
- `π` - Planned/next
### Document Headers
```markdown
# Document Title
**Purpose:** One-line purpose
**Date:** YYYY-MM-DD
**Status:** [WIP|COMPLETE|ARCHIVED]
**Related:** Links to related docs
---
## Content starts here
```
---
## π€ AI Agent Responsibilities
### Before Creating New Documents
1. **Check if document already exists**
```bash
find . -name "*keyword*.md"
```
2. **Check if information can be added to existing doc**
- Prefer updating over creating
- Use sections/subsections
3. **Determine correct location**
- Session-specific? β `work/` (temporary, gitignored)
- Teaching beginners? β `docs/tutorials/`
- Solving a problem? β `docs/how-to/`
- Technical reference? β `docs/reference/`
- Explaining concepts? β `docs/explanation/`
- Historical? β `docs/archive/`
4. **Ask the DiΓ‘taxis questions:**
- "Can you teach me to...?" β Tutorial
- "How do I...?" β How-To
- "What is...?" β Reference
- "Why...?" β Explanation
5. **Use descriptive names**
- Working docs: `session-notes.md`, `status.md` (in `work/`)
- Archived docs: `YYYY-MM-DD-description.md` (in `docs/archive/`)
- Tutorials: `getting-started.md`, `first-audit.md`
- How-To: `deploy.md`, `nix-flakes.md`
- Reference: `configuration.md`, `api.md`
- Explanation: `architecture.md`, `decisions.md`
6. **Choose correct file format**
- Use `.md` for all documentation (default)
- Use `.txt` ONLY for ASCII art visual summaries
- Archive `.txt` files immediately after session
### During Development
1. **Update status markers**
- Mark WIP β COMPLETE when done
- Update README.md status section
2. **Extract learnings as you go**
- Add gotchas to docs/learnings/
- Don't wait until cleanup
3. **Keep documentation DRY**
- Link to existing docs
- Don't duplicate information
### End of Session
1. **Clean up work/ directory (MANDATORY)**
- Archive valuable session docs to `docs/archive/YYYY-MM-DD-*.md`
- Delete temporary status reports
- Extract content to DiΓ‘taxis categories if needed
- Verify `work/` is empty (except README.md)
2. **Create session summary (if valuable)**
- Archive to `docs/archive/YYYY-MM-DD-session-summary.md`
- Include: accomplishments, next steps, blockers
3. **Update permanent docs**
- Sync README.md with reality
- Update relevant docs/ files
- Commit changes
4. **Verify clean state**
```bash
ls *.md # Should only show README.md, AGENTS.md
ls work/ # Should only show README.md
```
### Cleanup Time (End of Session)
1. **Review work/ directory**
```bash
ls -la work/
```
2. **Extract content to appropriate DiΓ‘taxis category:**
- Gotchas/solutions β `docs/how-to/`
- Technical facts β `docs/reference/`
- Concepts/design β `docs/explanation/`
- Lessons β `docs/tutorials/`
3. **Archive valuable session docs**
```bash
mv work/important-notes.md docs/archive/2025-11-04-session-notes.md
mv work/visual-summary.txt docs/archive/2025-11-04-visual-summary.txt
```
4. **Delete temporary files**
```bash
rm work/status.md
rm work/temp-notes.md
```
5. **Verify clean state**
```bash
ls *.md # Only README.md, AGENTS.md
ls work/ # Only README.md
```
6. **Commit permanent changes**
- Commit new/updated permanent docs
- Commit archived docs
- Note: work/ not committed (gitignored)
---
## π― Quality Checklist
### For Every Document
- [ ] Clear purpose stated at top
- [ ] Date included
- [ ] Status marker present
- [ ] Proper heading hierarchy (H1 β H2 β H3)
- [ ] Code blocks have language specified
- [ ] Links are valid and relative
- [ ] No duplicate information
- [ ] Spell-checked and readable
### For Working Documents
- [ ] Descriptive filename with date
- [ ] Will be archived or deleted when done
- [ ] Not duplicating permanent docs
- [ ] Learnings extracted to docs/learnings/
### For Permanent Documents
- [ ] In correct docs/ subdirectory
- [ ] Linked from docs/README.md
- [ ] Updated as project evolves
- [ ] No session-specific details
- [ ] Serves long-term purpose
### For Archived Documents
- [ ] Moved to docs/archive/
- [ ] Renamed with date prefix
- [ ] ARCHIVED marker at top (for .md files)
- [ ] Learnings extracted first (for .md files)
- [ ] Not referenced in active docs
### For .txt Files
- [ ] Contains only ASCII art/visual summaries
- [ ] Created in root for session use
- [ ] Archived immediately after session
- [ ] Not used for regular documentation
- [ ] Descriptive filename with purpose clear
---
## π Reference Documents
### Must Read
- **This file (AGENTS.md)** - Guidelines for documentation
- **README.md** - Project overview
- **docs/README.md** - Documentation navigation
### Key Technical Docs
- **docs/ARCHITECTURE.md** - System design
- **docs/TEST_STRATEGY.md** - Testing approach
- **docs/GETTING_STARTED.md** - Setup guide
### Learnings (Gotchas)
- **docs/learnings/nix-flakes.md** - Nix flake patterns
- **docs/learnings/nostr-sdk.md** - nostr-sdk notes
- **docs/learnings/git-http-backend.md** - Git protocol tips
---
## π Quick Links
- [Project README](README.md)
- [Documentation Index](docs/README.md)
- [Architecture](docs/ARCHITECTURE.md)
- [Learnings](docs/learnings/)
- [Archive](docs/archive/)
---
## π‘ Tips for Success
1. **Less is more** - Prefer updating over creating
2. **Archive often** - Keep root clean
3. **Extract learnings** - Make knowledge reusable
4. **Link, don't duplicate** - DRY applies to docs too
5. **Date everything** - Context is important
6. **Use descriptive names** - Future you will thank you
7. **Check before creating** - Document might already exist
8. **Update as you go** - Don't wait for cleanup time
9. **Use .md by default** - Only use .txt for ASCII art
10. **Archive .txt immediately** - Don't let them linger
---
## π Next Steps
After reading this:
1. **Review current documentation structure**
```bash
ls -la *.md
ls -la docs/
```
2. **Identify cleanup candidates**
- Completed working docs
- Obsolete duplicates
- Session summaries
3. **Extract learnings**
- Review completed docs
- Add to docs/learnings/
4. **Archive and clean**
- Move to docs/archive/
- Delete obsolete files
- Update links
5. **Commit changes**
```bash
git add .
git commit -m "docs: cleanup and reorganization"
```
---
**Remember:** Good documentation structure is like good code structure - it makes everything easier.
---
*Last updated: November 4, 2025*
*Status: β
Active guidelines*
|