|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is a Claude Code plugin called "Letter to Myself" that implements context persistence between Claude sessions. The plugin provides an agent and skill that automatically write structured "Last Will" summaries to a `.memory/` folder, enabling seamless continuity when sessions end, get compacted, or when days pass between work sessions. |
| 8 | + |
| 9 | +## Core Components |
| 10 | + |
| 11 | +### Plugin Structure |
| 12 | +- `.claude-plugin/plugin.json` - Plugin manifest defining name, version, and component paths |
| 13 | +- `agents/letter-for-my-future-self.md` - Agent persona that handles checkpoint creation |
| 14 | +- `skills/save-checkpoint/skill.md` - Skill that writes memory checkpoints to disk |
| 15 | +- `skills/vibe-init/skill.md` - Skill that sets up the Vibe Coding CI/CD pipeline |
| 16 | +- `CLAUDE_TEMPLATE.md` - Template users copy to their projects to enable the plugin |
| 17 | +- `install_agents.sh` - Installation script that sets up the plugin structure |
| 18 | + |
| 19 | +### Vibe Coding Pipeline (NEW) |
| 20 | +The plugin now includes a "Vibe Coding" feature that automatically transforms memory files into public-ready blog posts: |
| 21 | +- `.github/scripts/blog_gen.py` - Python script using Anthropic API for blog generation |
| 22 | +- `.github/scripts/vibe_requirements.txt` - Python dependencies (anthropic, python-dotenv) |
| 23 | +- `.github/workflows/vibe_publisher.yml` - GitHub Actions workflow triggered on .memory/ changes |
| 24 | +- `drafts/` - Output directory for generated blog posts |
| 25 | + |
| 26 | +### The Memory Protocol |
| 27 | +- Memory files are stored in `.memory/` as sequential markdown files (`letter_01.md`, `letter_02.md`, etc.) |
| 28 | +- Each file follows a strict template with sections: Executive Summary, Done List, Pain Log, Variable State, Next Steps |
| 29 | +- On startup, the agent reads the highest-numbered letter file to restore context |
| 30 | +- On checkpoint/exit, the agent generates a new letter with incremented number |
| 31 | + |
| 32 | +## Installation & Usage |
| 33 | + |
| 34 | +### Installing the Plugin |
| 35 | +```bash |
| 36 | +# Option A: Use the installation script (recommended) |
| 37 | +chmod +x install_agents.sh |
| 38 | +./install_agents.sh |
| 39 | + |
| 40 | +# Option B: Install as local plugin |
| 41 | +claude plugin install . --scope user |
| 42 | +``` |
| 43 | + |
| 44 | +### Adding to a Project |
| 45 | +Copy `CLAUDE_TEMPLATE.md` into the target project as `CLAUDE.md` (or merge if one exists). |
| 46 | + |
| 47 | +### Triggering Checkpoints |
| 48 | +The agent activates when users type: |
| 49 | +- `/checkpoint` |
| 50 | +- `exit` or indicates session is ending |
| 51 | +- "wrap up" |
| 52 | + |
| 53 | +### Setting Up Vibe Coding |
| 54 | +Initialize the blog generation pipeline by running: |
| 55 | +```bash |
| 56 | +/vibe-init |
| 57 | +``` |
| 58 | + |
| 59 | +This creates: |
| 60 | +1. Required directories (.memory/, drafts/, .github/scripts/, .github/workflows/) |
| 61 | +2. Blog generator script with Anthropic API integration |
| 62 | +3. GitHub Actions workflow for automatic blog post generation |
| 63 | +4. Python dependencies file |
| 64 | + |
| 65 | +**Required Setup:** |
| 66 | +Add `ANTHROPIC_API_KEY` to GitHub repository secrets (Settings → Secrets and variables → Actions) |
| 67 | + |
| 68 | +**How It Works:** |
| 69 | +1. Push changes to `.memory/*.md` files |
| 70 | +2. GitHub Actions automatically triggers |
| 71 | +3. Latest memory file is converted to blog post using Claude |
| 72 | +4. Pull request created with generated draft in `drafts/` |
| 73 | +5. Review and merge when ready |
| 74 | + |
| 75 | +## Memory Versioning |
| 76 | + |
| 77 | +See `MEMORY_VERSIONING.md` for comprehensive Git workflows: |
| 78 | +- **Option A**: Full versioning (recommended for solo projects) |
| 79 | +- **Option B**: Clean diffs with `.gitattributes` configuration |
| 80 | +- **Option C**: Team workflow with shared/private split |
| 81 | +- **Option D**: Security guardrails to prevent secrets in memory |
| 82 | +- **Option E**: Keep history clean with filtered logs or orphan branches |
| 83 | +- **Option F**: Archiving strategies for long-running projects |
| 84 | + |
| 85 | +Key commands for memory management: |
| 86 | +```bash |
| 87 | +# Commit memory after session |
| 88 | +git add .memory/shared |
| 89 | +git commit -m "chore(memory): session handoff" |
| 90 | + |
| 91 | +# Scan for secrets before committing |
| 92 | +rg -n --hidden --glob ".memory/**" -e "AKIA[0-9A-Z]{16}" -e "BEGIN( RSA)? PRIVATE KEY" .memory |
| 93 | +``` |
| 94 | + |
| 95 | +## Architecture Notes |
| 96 | + |
| 97 | +### Plugin Design Philosophy |
| 98 | +- **Continuity over context**: Addresses the fundamental limitation of Claude's context window by creating persistent memory |
| 99 | +- **Minimal friction**: Automatic checkpoint creation on session end |
| 100 | +- **Structured format**: Strict template ensures consistent, actionable handoffs |
| 101 | +- **Pain Log emphasis**: Critical section for documenting failures and workarounds to prevent repeated mistakes |
| 102 | + |
| 103 | +### Agent Behavior |
| 104 | +The `letter-for-my-future-self` agent operates in two modes: |
| 105 | +1. **Normal mode**: Acts as a standard coding assistant |
| 106 | +2. **Checkpoint mode**: Triggered by exit signals, stops all work to review conversation history and generate a summary |
| 107 | + |
| 108 | +### Skill Execution |
| 109 | +The `save-checkpoint` skill: |
| 110 | +1. Creates `.memory/` directory if needed |
| 111 | +2. Lists existing letter files to determine next sequential number |
| 112 | +3. Writes the generated letter using the Write tool |
| 113 | +4. Confirms to user with filename |
| 114 | + |
| 115 | +## File Organization |
| 116 | + |
| 117 | +``` |
| 118 | +. |
| 119 | +├── .claude-plugin/ |
| 120 | +│ └── plugin.json # Plugin manifest |
| 121 | +├── agents/ |
| 122 | +│ └── letter-for-my-future-self.md # Agent persona definition |
| 123 | +├── skills/ |
| 124 | +│ └── save-checkpoint/ |
| 125 | +│ └── skill.md # Checkpoint skill definition |
| 126 | +├── CLAUDE_TEMPLATE.md # Template for user projects |
| 127 | +├── install_agents.sh # Installation script |
| 128 | +├── MEMORY_VERSIONING.md # Git workflow guide |
| 129 | +├── QUICK_START.md # User installation guide |
| 130 | +└── README.md # Project documentation |
0 commit comments