2025-07-21 12:52:39 -04:00
# cnotes - Git Notes for Claude Conversations
2025-07-21 10:12:28 -04:00
2025-07-21 16:55:41 -04:00
**cnotes** automatically captures Claude conversation context in [git notes ](https://git-scm.com/docs/git-notes ) using [Claude hooks ](https://docs.anthropic.com/en/docs/claude-code/hooks ), making it easy to understand the development history and reasoning behind each commit. The tool shows a conversational transcript of user prompts, tool uses, and Claude's responses.
2025-07-21 10:12:28 -04:00
2025-07-21 13:30:43 -04:00
⭐️ `cnotes` is pronounced like 💵 c-notes or 🏊 [_cenotes_ ](https://en.wikipedia.org/wiki/Cenote )
2025-07-21 13:02:15 -04:00
2025-07-21 12:52:39 -04:00
## Quick Start
2025-07-21 10:12:28 -04:00
```bash
2025-07-21 12:52:39 -04:00
# Build and install
2025-07-21 13:02:15 -04:00
go install github.com/imjasonh/cnotes
cnotes install
2025-07-21 10:12:28 -04:00
2025-07-21 16:55:41 -04:00
# Note: you may need to restart `claude` to pick up the new hooks
2025-07-21 12:52:39 -04:00
# Now every git commit made through Claude will have conversation context attached!
2025-07-21 10:12:28 -04:00
2025-07-21 12:52:39 -04:00
# View conversation notes for the latest commit
2025-07-21 13:02:15 -04:00
cnotes show
2025-07-21 10:12:28 -04:00
2025-07-21 12:52:39 -04:00
# View notes for a specific commit
2025-07-21 13:02:15 -04:00
cnotes show abc1234
2025-07-21 10:12:28 -04:00
2025-07-21 12:52:39 -04:00
# List all commits with conversation notes
2025-07-21 13:02:15 -04:00
cnotes list
2025-07-21 10:12:28 -04:00
```
2025-07-21 12:52:39 -04:00
## What It Does
2025-07-21 10:17:58 -04:00
2025-07-21 12:52:39 -04:00
When you work with Claude and make git commits, cnotes automatically:
2025-07-21 12:27:12 -04:00
2025-07-21 12:52:39 -04:00
1. **Detects git commit commands** in your Claude conversation
2. **Captures conversation context** including user prompts and tool interactions
3. **Attaches structured notes** to the commit using `git notes`
4. **Preserves context** across rebases, squashes, and other git operations
2025-07-21 12:27:12 -04:00
2025-07-21 12:52:39 -04:00
## Installation
2025-07-21 12:27:12 -04:00
```bash
2025-07-21 12:52:39 -04:00
# Install to project settings (recommended)
2025-07-21 13:02:15 -04:00
cnotes install
2025-07-21 12:52:39 -04:00
# Install globally
2025-07-21 13:02:15 -04:00
cnotes install --global
2025-07-21 12:27:12 -04:00
2025-07-21 12:52:39 -04:00
# Install locally
2025-07-21 13:02:15 -04:00
cnotes install --local
2025-07-21 12:27:12 -04:00
2025-07-21 12:52:39 -04:00
# Uninstall
2025-07-21 13:02:15 -04:00
cnotes install --uninstall
2025-07-21 12:27:12 -04:00
```
2025-07-21 12:52:39 -04:00
This configures Claude Code to call cnotes as a hook handler when you make git commits.
2025-07-21 12:27:12 -04:00
2025-07-21 12:52:39 -04:00
## Viewing Conversation Notes
2025-07-21 12:27:12 -04:00
2025-07-21 12:52:39 -04:00
### Pretty-Printed Format (Recommended)
2025-07-21 12:27:12 -04:00
```bash
2025-07-21 12:52:39 -04:00
# Show notes for the latest commit
2025-07-21 13:02:15 -04:00
cnotes show
2025-07-21 12:27:12 -04:00
2025-07-21 12:52:39 -04:00
# Show notes for a specific commit
2025-07-21 13:02:15 -04:00
cnotes show abc1234
2025-07-21 12:27:12 -04:00
2025-07-21 12:52:39 -04:00
# List all commits with notes
2025-07-21 13:02:15 -04:00
cnotes list
2025-07-21 12:27:12 -04:00
```
### Example Output
2025-07-21 12:43:34 -04:00
```markdown
# Claude Conversation Notes
**Commit:** `abc1234 Add user authentication with password validation`
**Session ID:** `claude_session_20250121_143022`
**Timestamp:** 2025-01-21 14:30:45 EST
**Claude Version:** claude-sonnet-4-20250514
**Tools Used:** Edit, Write, Bash
## Commit Context
```
Git command: git commit -m "Add user authentication with password validation"
Result: [main abc1234] Add user authentication with password validation
```
## Conversation Context
Recent user prompts:
- Add user authentication to the login form
- Make sure to use bcrypt for password hashing
Tool interactions:
- Edit: components/LoginForm.jsx
- Write: utils/auth.js
- Bash: npm install bcrypt
---
2025-07-21 13:02:15 -04:00
💡 *Generated by `cnotes`*
2025-07-21 12:52:39 -04:00
```
### Raw Git Notes Commands
```bash
# View raw notes
git notes --ref=claude-conversations show HEAD
# View in git log
git log --show-notes=claude-conversations --oneline
```
## Backup and Restore
cnotes includes comprehensive backup functionality to protect against data loss during rebasing, squashing, or other destructive git operations:
```bash
# Backup all conversation notes
2025-07-21 13:02:15 -04:00
cnotes backup my-notes-backup.json
2025-07-21 12:52:39 -04:00
# Restore notes from backup
2025-07-21 13:02:15 -04:00
cnotes restore my-notes-backup.json
2025-07-21 12:52:39 -04:00
# View all commits with notes
2025-07-21 13:02:15 -04:00
cnotes list
2025-07-21 12:27:12 -04:00
```
2025-07-21 12:52:39 -04:00
### Automatic Protection
2025-07-21 12:27:12 -04:00
2025-07-21 12:52:39 -04:00
The system automatically:
- **Warns before destructive operations** like `git rebase` , `git reset --hard`
- **Configures git to preserve notes** during rebase operations
- **Provides backup commands** for manual recovery
## Configuration
Customize behavior by creating `.claude/notes.json` :
2025-07-21 12:27:12 -04:00
```json
{
"enabled": true,
"max_excerpt_length": 5000,
"max_prompts": 2,
"include_tool_output": false,
"notes_ref": "claude-conversations",
"exclude_patterns": ["password", "token", "key", "secret"]
}
```
### Privacy Controls
The system includes built-in privacy protections:
- Automatically filters sensitive patterns (passwords, tokens, keys)
- Limits excerpt length to prevent excessive data storage
- Only includes conversation context from the current session
- Configurable exclusion patterns
- Option to disable entirely (`"enabled": false` )
2025-07-21 12:52:39 -04:00
## How It Works
2025-07-21 12:27:12 -04:00
2025-07-21 12:52:39 -04:00
1. **Hook Integration** : cnotes integrates with Claude Code as a PostToolUse hook handler
2. **Git Command Detection** : Monitors bash commands for `git commit` operations
3. **Context Extraction** : Parses Claude transcript files to extract relevant conversation context
4. **Note Creation** : Stores structured JSON data using `git notes --ref=claude-conversations`
5. **Hash Preservation** : Automatically configures git to preserve notes during rewrites
2025-07-21 12:27:12 -04:00
2025-07-21 12:52:39 -04:00
## Architecture
2025-07-21 12:40:04 -04:00
2025-07-21 12:52:39 -04:00
- **`cnotes` ** - Main binary that handles Claude Code hook calls
- **`cnotes show` ** - Pretty-print conversation notes in Markdown format
- **`cnotes install` ** - Configure Claude Code to use cnotes
- **`cnotes backup/restore` ** - Backup and restore conversation notes
- **`cnotes list` ** - List all commits with conversation notes
2025-07-21 12:40:04 -04:00
2025-07-21 12:52:39 -04:00
## Requirements
2025-07-21 12:40:04 -04:00
2025-07-21 12:52:39 -04:00
- Go 1.24+
- Claude Code CLI
- Git repository
2025-07-21 12:40:04 -04:00
2025-07-21 12:52:39 -04:00
## Development
2025-07-21 12:40:04 -04:00
```bash
2025-07-21 12:52:39 -04:00
# Clone and build
git clone https://github.com/imjasonh/cnotes
cd cnotes
go build -o cnotes
2025-07-21 12:40:04 -04:00
2025-07-21 12:52:39 -04:00
# Install for development
2025-07-21 13:02:15 -04:00
cnotes install
2025-07-21 12:43:34 -04:00
2025-07-21 12:52:39 -04:00
# Test manually (simulates Claude Code calling it)
2025-07-21 13:02:15 -04:00
echo '{"hook_event_name":"PostToolUse",...}' | cnotes
2025-07-21 12:40:04 -04:00
```
2025-07-21 12:52:39 -04:00
## Sharing Git Notes
2025-07-21 12:40:04 -04:00
2025-07-21 12:52:39 -04:00
Git notes are local by default. To share with your team:
2025-07-21 10:12:28 -04:00
```bash
2025-07-21 12:52:39 -04:00
# Push notes to remote
git push origin refs/notes/claude-conversations
2025-07-21 10:12:28 -04:00
2025-07-21 12:52:39 -04:00
# Pull notes from remote
git fetch origin refs/notes/claude-conversations:refs/notes/claude-conversations
2025-07-21 10:12:28 -04:00
2025-07-21 12:52:39 -04:00
# Configure automatic notes syncing
git config remote.origin.fetch '+refs/notes/*:refs/notes/*'
2025-07-21 10:12:28 -04:00
```
2025-07-21 12:52:39 -04:00
---
2025-07-21 10:12:28 -04:00
2025-07-21 13:02:15 -04:00
**⚠️ Security Notice**: cnotes executes as a Claude Code hook handler. Ensure your installation is secure and trusted.