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
|
# 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 maintain a **clean, hierarchical documentation structure** to avoid documentation sprawl. All working documents have a defined lifecycle and location.
```
ngit-grasp/
├── README.md # Project overview (keep updated)
├── AGENTS.md # This file - agent guidelines
├── CHANGELOG.md # User-facing changes (semver)
│
├── docs/ # Permanent technical documentation
│ ├── README.md # Docs navigation guide
│ ├── ARCHITECTURE.md # System architecture
│ ├── TEST_STRATEGY.md # Testing approach
│ ├── GIT_PROTOCOL.md # Git protocol reference
│ ├── COMPARISON.md # vs other implementations
│ ├── GETTING_STARTED.md # Setup guide
│ └── DECISION_SUMMARY.md # Key architectural decisions
│
├── docs/archive/ # Completed session/phase docs
│ ├── 2025-11-04-tag-migration.md
│ ├── 2025-11-04-flake-migration.md
│ ├── 2025-11-04-cleanup-visual-summary.txt # Visual summaries
│ └── 2025-11-03-architecture-investigation.md
│
├── docs/learnings/ # Extracted knowledge (permanent)
│ ├── nix-flakes.md # Flake gotchas and patterns
│ ├── nostr-sdk.md # nostr-sdk patterns and upgrades
│ └── git-http-backend.md # Git protocol learnings
│
├── grasp-audit/ # Audit tool subproject
│ ├── README.md # Main audit docs
│ ├── QUICK_START.md # Getting started
│ └── docs/
│ └── archive/ # Audit-specific archives
│
└── .ai/ # AI assistant context (ignored in git)
└── history/ # Conversation history
```
### 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 (Root Level)
**Purpose:** Active development, session notes, status reports
**Location:** Project root
**Lifecycle:** Created → Updated → Archived
**Retention:** Archive after completion, delete if obsolete
**Examples:**
- `TAG_MIGRATION_COMPLETE.md` → Archive when next phase starts
- `SESSION_2025_11_04_SUMMARY.md` → Archive at session end
- `NEXT_STEPS.md` → Update continuously, archive when complete
- `STATUS_VISUAL.txt` → Archive immediately after session
**Rules:**
- ✅ Use descriptive names with dates: `YYYY-MM-DD-description.md`
- ✅ Mark status clearly: `[WIP]`, `[COMPLETE]`, `[ARCHIVED]`
- ✅ Include date and context at top
- ✅ Use `.md` for docs, `.txt` only for ASCII art summaries
- ❌ Don't let root accumulate more than 5-10 working docs
- ❌ Don't create duplicates (merge or link instead)
- ❌ Don't keep `.txt` files in root (archive immediately)
### 2. Permanent Documentation (docs/)
**Purpose:** Long-term reference, architecture, guides
**Location:** `docs/`
**Lifecycle:** Created → Maintained → Updated
**Retention:** Permanent (version controlled)
**Examples:**
- `docs/ARCHITECTURE.md` - System design
- `docs/TEST_STRATEGY.md` - Testing approach
- `docs/learnings/nix-flakes.md` - Extracted knowledge
**Rules:**
- ✅ 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
### 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 (docs/learnings/)
**Purpose:** Reusable knowledge, gotchas, patterns
**Location:** `docs/learnings/`
**Lifecycle:** Extracted → Maintained → Updated
**Retention:** Permanent (living documents)
**Examples:**
- `docs/learnings/nix-flakes.md` - Flake patterns and gotchas
- `docs/learnings/nostr-sdk.md` - SDK upgrade notes
- `docs/learnings/git-http-backend.md` - Git protocol tips
**Rules:**
- ✅ Extract from session docs before archiving
- ✅ Organize by topic, not by session
- ✅ Include code examples
- ✅ Update as we learn more
- ❌ Don't duplicate official docs (link instead)
---
## 🔄 Cleanup Process
### When to Clean Up
**Trigger:** Root directory has >10 markdown files OR any .txt files
**Frequency:** End of each major phase or weekly
**Responsibility:** AI agents should proactively suggest cleanup
### Cleanup Steps
1. **Identify Completed Documents**
```bash
# Find old working docs
ls -lt *.md | head -20
# Check for .txt files (should always be archived)
ls -la *.txt
```
2. **Extract Learnings**
- Review each completed doc
- Extract gotchas, patterns, solutions
- Add to appropriate `docs/learnings/*.md`
3. **Archive Completed Work**
```bash
# Archive markdown with date prefix
mv TAG_MIGRATION_COMPLETE.md docs/archive/2025-11-04-tag-migration.md
# Archive .txt files immediately
mv STATUS_VISUAL.txt docs/archive/2025-11-04-status-visual.txt
```
4. **Delete Obsolete Documents**
- Duplicates (keep most recent/complete)
- Superseded documents
- Pure status reports (no learnings)
5. **Update References**
- Update links in active docs
- Update README.md if needed
- Commit changes
### Example Cleanup
```bash
# Before cleanup (36 files in root!)
ls *.md | wc -l
# 36
ls *.txt | wc -l
# 5
# After cleanup (3-5 files in root)
ls *.md
# README.md
# AGENTS.md
# CURRENT_STATUS.md
ls *.txt
# (none - all archived)
# Archived
ls docs/archive/
# 2025-11-04-tag-migration.md
# 2025-11-04-flake-migration.md
# 2025-11-04-cleanup-visual-summary.txt
# 2025-11-03-architecture-investigation.md
# ...
# Learnings extracted
ls docs/learnings/
# nix-flakes.md
# nostr-sdk.md
# git-http-backend.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**
- Working doc → Root
- Permanent → docs/
- Learning → docs/learnings/
- Historical → docs/archive/
4. **Use descriptive names with dates**
- `YYYY-MM-DD-description.md` for working docs
- `topic-name.md` for permanent docs
5. **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. **Suggest cleanup if needed**
- Count root .md files
- Suggest archiving completed docs
2. **Create session summary**
- What was accomplished
- What's next
- Any blockers
3. **Update permanent docs**
- Sync README.md with reality
- Update relevant docs/ files
### Cleanup Time
1. **Review all root .md and .txt files**
2. **Extract learnings to docs/learnings/**
3. **Archive completed work to docs/archive/**
- `.md` files: Extract learnings first
- `.txt` files: Archive immediately (no extraction needed)
4. **Delete obsolete duplicates**
5. **Update links in active docs**
6. **Commit with clear message**
---
## 🎯 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*
|