Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

Commit 07e7a92

Browse files
zircoteclaude
andcommitted
docs: add API Reference, environment variables, and command help (DOC-003, DOC-005, DOC-008)
README.md: - Add comprehensive API Reference section with services, models, operations - Document all environment variables with descriptions and defaults - Add Hook Configuration section with all hook-specific variables CLAUDE.md: - Add Code Intelligence (LSP) section with hook documentation - Add Navigation & Understanding guidance - Add Verification Workflow and Pre-Edit Checklist commands/*.md: - Add consistent --help support with man-page style output - Add help_check sections for early help detection Addresses: DOC-003 (API Reference), DOC-005 (environment variables), DOC-008 (Related Commands) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 5f3afd8 commit 07e7a92

8 files changed

Lines changed: 490 additions & 31 deletions

File tree

CLAUDE.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,41 @@ def capture_service(tmp_path, monkeypatch):
187187
| `HOOK_DEBUG` | Enable debug logging to stderr | `false` |
188188
| `HOOK_SESSION_START_INCLUDE_GUIDANCE` | Include response guidance templates | `true` |
189189
| `HOOK_SESSION_START_GUIDANCE_DETAIL` | Guidance level: minimal/standard/detailed | `standard` |
190+
191+
## Code Intelligence (LSP)
192+
193+
LSP hooks are configured in `.claude/hooks.json` for immediate feedback on Python edits.
194+
195+
### Installed Hooks
196+
197+
| Hook | Trigger | Action |
198+
|------|---------|--------|
199+
| `format-on-edit` | PostToolUse (Write/Edit) | Runs `ruff format` on changed files |
200+
| `lint-check-on-edit` | PostToolUse (Write/Edit) | Runs `ruff check` on changed files |
201+
| `typecheck-on-edit` | PostToolUse (Write/Edit) | Runs `mypy` on changed files |
202+
| `pre-commit-quality-gate` | PreToolUse (git commit) | Runs full `make quality` before commit |
203+
204+
### Navigation & Understanding
205+
206+
- Use LSP `goToDefinition` before modifying unfamiliar functions, classes, or modules
207+
- Use LSP `findReferences` before refactoring any symbol to understand full impact
208+
- Use LSP `documentSymbol` to get file structure overview before major edits
209+
- Prefer LSP navigation over grep—it resolves through imports and re-exports
210+
211+
### Verification Workflow
212+
213+
1. After each edit, check hook output for lint/type errors
214+
2. Fix errors immediately before proceeding
215+
3. Run `make quality` before committing
216+
217+
### Pre-Edit Checklist
218+
219+
- [ ] Navigate to definition to understand implementation
220+
- [ ] Find all references to assess change impact
221+
- [ ] Review type annotations via hover before modifying function signatures
222+
223+
### Error Handling
224+
225+
- If hooks report errors, fix them before proceeding to the next task
226+
- Type errors are blocking in this project (mypy strict mode)
227+
- Use hook output to guide fixes, not guesswork

README.md

Lines changed: 83 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,63 @@ recall = get_recall_service()
5757
memories = recall.search("database choice", namespace="decisions", limit=5)
5858
```
5959

60+
## API Reference
61+
62+
### Core Services
63+
64+
The library exposes three primary service interfaces via factory functions:
65+
66+
| Service | Factory Function | Description |
67+
|---------|-----------------|-------------|
68+
| `CaptureService` | `get_capture_service()` | Capture memories with validation, git notes storage, and indexing |
69+
| `RecallService` | `get_recall_service()` | Search memories using semantic (vector) or text-based queries |
70+
| `SyncService` | `get_sync_service()` | Synchronize the SQLite index with git notes, verify consistency |
71+
72+
### Key Models
73+
74+
All models are immutable dataclasses (`frozen=True`) for thread-safety:
75+
76+
| Model | Description |
77+
|-------|-------------|
78+
| `Memory` | Core entity representing a captured memory (id, namespace, summary, content, timestamp, tags) |
79+
| `MemoryResult` | Memory with similarity distance score from vector search |
80+
| `CaptureResult` | Result of capture operation (success, memory, indexed, warning) |
81+
| `IndexStats` | Statistics about the memory index (total, by_namespace, by_spec, last_sync) |
82+
| `HydrationLevel` | Enum for progressive loading: `SUMMARY`, `FULL`, `FILES` |
83+
84+
### Common Operations
85+
86+
```python
87+
from git_notes_memory import get_capture_service, get_recall_service, get_sync_service
88+
89+
# Capture with tags
90+
capture = get_capture_service()
91+
result = capture.capture(
92+
namespace="learnings",
93+
summary="pytest fixtures can be module-scoped",
94+
content="Use @pytest.fixture(scope='module') for expensive setup",
95+
tags=["pytest", "testing"],
96+
)
97+
98+
# Semantic search with filters
99+
recall = get_recall_service()
100+
results = recall.search(
101+
query="database configuration",
102+
k=10, # max results
103+
namespace="decisions", # filter by namespace
104+
min_similarity=0.5, # minimum relevance threshold
105+
)
106+
107+
# Sync and verify index
108+
sync = get_sync_service()
109+
sync.reindex(full=True) # full reindex from git notes
110+
verification = sync.verify_consistency()
111+
if not verification.is_consistent:
112+
sync.repair(verification)
113+
```
114+
115+
For complete API documentation, see the [Developer Guide](docs/DEVELOPER_GUIDE.md).
116+
60117
## Claude Code Plugin
61118

62119
When used as a Claude Code plugin, the following slash commands are available:
@@ -102,27 +159,48 @@ make quality
102159

103160
## Configuration
104161

105-
Environment variables (see `.env.example` for all options):
162+
### Core Settings
106163

107164
| Variable | Description | Default |
108165
|----------|-------------|---------|
109-
| `MEMORY_PLUGIN_DATA_DIR` | Data directory path | `~/.local/share/memory-plugin/` |
110-
| `MEMORY_PLUGIN_GIT_NAMESPACE` | Git notes namespace | `refs/notes/mem` |
111-
| `MEMORY_PLUGIN_EMBEDDING_MODEL` | Embedding model name | `all-MiniLM-L6-v2` |
166+
| `MEMORY_PLUGIN_DATA_DIR` | Data directory for index and models | `~/.local/share/memory-plugin/` |
167+
| `MEMORY_PLUGIN_GIT_NAMESPACE` | Git notes ref prefix | `refs/notes/mem` |
168+
| `MEMORY_PLUGIN_EMBEDDING_MODEL` | Sentence-transformer model | `all-MiniLM-L6-v2` |
112169
| `MEMORY_PLUGIN_AUTO_CAPTURE` | Enable auto-capture hook | `false` |
113170

114171
### Hook Configuration
115172

116173
| Variable | Description | Default |
117174
|----------|-------------|---------|
118-
| `HOOK_ENABLED` | Master switch for hooks | `true` |
175+
| `HOOK_ENABLED` | Master switch for all hooks | `true` |
119176
| `HOOK_SESSION_START_ENABLED` | Enable SessionStart context injection | `true` |
177+
| `HOOK_SESSION_START_INCLUDE_GUIDANCE` | Include response guidance templates | `true` |
178+
| `HOOK_SESSION_START_GUIDANCE_DETAIL` | Guidance level: minimal/standard/detailed | `standard` |
120179
| `HOOK_USER_PROMPT_ENABLED` | Enable signal detection in prompts | `false` |
121180
| `HOOK_POST_TOOL_USE_ENABLED` | Enable file-contextual memory injection | `true` |
181+
| `HOOK_POST_TOOL_USE_MIN_SIMILARITY` | Minimum similarity threshold | `0.6` |
182+
| `HOOK_POST_TOOL_USE_MAX_RESULTS` | Maximum memories to inject | `3` |
183+
| `HOOK_POST_TOOL_USE_AUTO_CAPTURE` | Auto-capture from written content | `true` |
122184
| `HOOK_PRE_COMPACT_ENABLED` | Enable auto-capture before compaction | `true` |
185+
| `HOOK_PRE_COMPACT_AUTO_CAPTURE` | Auto-capture without prompt | `true` |
186+
| `HOOK_PRE_COMPACT_PROMPT_FIRST` | Suggestion mode (show, don't capture) | `false` |
187+
| `HOOK_PRE_COMPACT_MIN_CONFIDENCE` | Minimum confidence for capture | `0.85` |
188+
| `HOOK_PRE_COMPACT_MAX_CAPTURES` | Maximum captures per compaction | `3` |
123189
| `HOOK_STOP_ENABLED` | Enable Stop hook processing | `true` |
190+
| `HOOK_STOP_SYNC_INDEX` | Sync index on session end | `true` |
191+
| `HOOK_STOP_PROMPT_UNCAPTURED` | Prompt for uncaptured content | `true` |
124192
| `HOOK_DEBUG` | Enable debug logging to stderr | `false` |
125193

194+
### Performance Tuning
195+
196+
| Variable | Description | Default |
197+
|----------|-------------|---------|
198+
| `HOOK_SESSION_START_TOKEN_BUDGET` | Max tokens for context injection | `2000` |
199+
| `HOOK_POST_TOOL_USE_TIMEOUT` | Hook timeout in seconds | `5` |
200+
| `HOOK_PRE_COMPACT_TIMEOUT` | Hook timeout in seconds | `15` |
201+
202+
See `.env.example` for the complete list of configuration options.
203+
126204
## Requirements
127205

128206
- Python 3.11+

commands/capture.md

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,46 @@ argument-hint: "[namespace] <summary> -- <content>"
44
allowed-tools: ["Bash", "Write", "Read", "AskUserQuestion"]
55
---
66

7+
<help_check>
8+
## Help Check
9+
10+
If `$ARGUMENTS` contains `--help` or `-h`:
11+
12+
**Output this help and HALT (do not proceed further):**
13+
14+
<help_output>
15+
```
16+
CAPTURE(1) User Commands CAPTURE(1)
17+
18+
NAME
19+
capture - Capture a memory (decision, learning, blocker, progress...
20+
21+
SYNOPSIS
22+
/memory:capture [namespace] <summary> -- <content>
23+
24+
DESCRIPTION
25+
Capture a memory (decision, learning, blocker, progress, etc.) to the git-backed memory system
26+
27+
OPTIONS
28+
--help, -h Show this help message
29+
30+
EXAMPLES
31+
/memory:capture
32+
/memory:capture <namespace>
33+
/memory:capture --help
34+
35+
SEE ALSO
36+
/memory:* for related commands
37+
38+
CAPTURE(1)
39+
```
40+
</help_output>
41+
42+
**After outputting help, HALT immediately. Do not proceed with command execution.**
43+
</help_check>
44+
45+
---
46+
747
# /memory:capture - Capture a Memory
848

949
Capture information to the git-backed memory system for later retrieval.
@@ -12,7 +52,7 @@ Capture information to the git-backed memory system for later retrieval.
1252

1353
You will help the user capture a memory. The memory will be stored as a git note and indexed for semantic search.
1454

15-
### Step 1: Parse the Arguments
55+
<step number="1" name="Parse the Arguments">
1656

1757
**Arguments format**: `$ARGUMENTS`
1858

@@ -31,14 +71,18 @@ If no namespace specified, auto-detect based on content patterns:
3171
- Contains "pattern", "recurring", "often" → `patterns`
3272
- Default → `learnings`
3373

34-
### Step 2: Validate Content
74+
</step>
75+
76+
<step number="2" name="Validate Content">
3577

3678
If `$ARGUMENTS` is empty or very short (< 10 characters):
3779
- Use AskUserQuestion to prompt for the memory content
3880
- Question: "What would you like to capture?"
3981
- Provide examples for each memory type
4082

41-
### Step 3: Capture the Memory
83+
</step>
84+
85+
<step number="3" name="Capture the Memory">
4286

4387
Use Bash to invoke the Python library:
4488

@@ -69,7 +113,9 @@ Replace:
69113
- `$SUMMARY` with a one-line summary (max 100 chars, escape quotes)
70114
- `$CONTENT` with the full content (escape quotes)
71115

72-
### Step 4: Confirm to User
116+
</step>
117+
118+
<step number="4" name="Confirm to User">
73119

74120
Show the result:
75121
```
@@ -83,6 +129,8 @@ This memory will be available for recall in future sessions.
83129
Use `/memory:recall` to retrieve it.
84130
```
85131

132+
</step>
133+
86134
## Namespace Reference
87135

88136
| Namespace | Use For | Example |
@@ -108,13 +156,15 @@ For structured captures, the library also provides:
108156
- `capture_pattern(summary, pattern_type, evidence, confidence)` - Patterns
109157
- `capture_review(spec, summary, findings, verdict)` - Code reviews
110158

111-
## Error Handling
159+
<error_handling>
112160

113161
If the capture fails:
114162
1. Check if we're in a git repository: `git rev-parse --git-dir`
115163
2. Check if the library is installed: `uv run python3 -c "import git_notes_memory"`
116164
3. Show helpful error message with recovery action
117165

166+
</error_handling>
167+
118168
## Examples
119169

120170
**User**: `/memory:capture decisions Use Redis for session storage -- Due to built-in expiration and cluster support`
@@ -131,9 +181,20 @@ If the capture fails:
131181
After successfully capturing a memory, remind the user:
132182

133183
```
134-
💡 **Pro tip**: You can capture memories inline using markers:
184+
**Pro tip**: You can capture memories inline using markers:
135185
- `[remember] <insight>` - Captures a learning
136186
- `[capture] <decision>` - Captures any type of memory
137187
- `@memory <content>` - Same as [capture]
138188
139189
These markers work anywhere in your message and are automatically processed.
190+
```
191+
192+
## Related Commands
193+
194+
| Command | Description |
195+
|---------|-------------|
196+
| `/memory:recall` | Search and retrieve captured memories semantically |
197+
| `/memory:search` | Advanced search with filtering options |
198+
| `/memory:status` | View memory system statistics and health |
199+
| `/memory:sync` | Synchronize the index with git notes |
200+
| `/memory:validate` | Validate the memory system is working correctly |

0 commit comments

Comments
 (0)