Skip to content

Latest commit

 

History

History
279 lines (211 loc) · 10.6 KB

File metadata and controls

279 lines (211 loc) · 10.6 KB

Claude Code MindPalace

Your commits look like this:

fix typo
update user  
it works
more changes
fix bug

Stop thinking about git. Start building.

🧠 Intelligent Git automation for Claude Code that never lets you lose work and builds toward persistent AI context.


The Transformation

Your messy commits become this:

feat(auth): implement user authentication system
- Add email validation with real-time feedback
- Create JWT token generation and verification  
- Implement protected route guards
- Add password strength validation

How? Every file change = automatic descriptive commit. When tasks complete = automatic professional squashing. Zero effort from you.


✅ What You Get

🔄 Auto-Checkpoint Every Change

  • Every file modification = immediate descriptive commit
  • Never lose work again - each change safely stored
  • AI-generated commit messages that actually make sense

🧠 Intelligent Squashing

  • Automatically combines checkpoint commits into meaningful task commits
  • Uses conventional commit format (feat:, fix:, refactor:)
  • Clean professional git history without manual effort

🛡️ Zero Maintenance

  • Works completely automatically with Claude Code hooks
  • Universal language support (Node.js, Rust, Python, any project)
  • Duplicate protection and error handling built-in

🚀 Installation

Prerequisites

  • Claude Code installed
  • Git repository with user configured (git config user.name and git config user.email)

Optional: Code Formatting

The system auto-detects and runs your existing formatters:

  • Node.js: npm run lint:fix or pnpm run lint:fix (requires ESLint/Prettier setup)
  • Rust: cargo fmt (built into Cargo)
  • Python: black . or ruff format . (install via pip install black or pip install ruff)

If formatters aren't installed, the system works fine without them.

Complete Setup

1. Create Claude Code settings file:

# For this project only
mkdir -p .claude && touch .claude/settings.json

# OR for all projects globally  
mkdir -p ~/.claude && touch ~/.claude/settings.json

2. Add this configuration to your settings.json:

{
  "hooks": {
    "preToolUse": {
      "command": "bash",
      "args": ["-c", "if [ -f package.json ]; then npm run lint:fix 2>/dev/null || pnpm run lint:fix 2>/dev/null || true; elif [ -f Cargo.toml ]; then cargo fmt 2>/dev/null || true; elif command -v black >/dev/null; then black . 2>/dev/null || true; elif command -v ruff >/dev/null; then ruff format . 2>/dev/null || true; fi"],
      "timeout": 30000
    },
    "postToolUse": {
      "command": "bash", 
      "args": ["-c", "if [ -d .git ] && [ -n \"$(git status --porcelain)\" ]; then LOCKFILE=\"/tmp/claude_hooks_lock_$$\"; if ! [ -f \"$LOCKFILE\" ]; then touch \"$LOCKFILE\"; DIFF=$(git diff --name-only --diff-filter=M | head -10 | tr '\\n' ' '); if [ -n \"$DIFF\" ]; then MSG=$(claude -p \"Generate a concise commit message for these changes. Format: 'checkpoint: [what was done] - [HH:MM]'. Be specific about the actual changes made. Files: $DIFF. Diff: $(git diff --no-color | head -50)\" 2>/dev/null | head -1 | sed 's/^[^:]*:/checkpoint:/' || echo \"checkpoint: update files $DIFF - $(date +%H:%M)\"); git add -A && git commit -m \"$MSG\" 2>/dev/null || true; fi; rm -f \"$LOCKFILE\"; fi; fi"],
      "timeout": 60000
    },
    "stop": {
      "command": "bash",
      "args": ["-c", "if [ -d .git ]; then LOCKFILE=\"/tmp/claude_squash_lock_$$\"; if ! [ -f \"$LOCKFILE\" ]; then touch \"$LOCKFILE\"; CHECKPOINT_COUNT=$(git log --oneline --grep=\"^checkpoint:\" | head -20 | wc -l); if [ \"$CHECKPOINT_COUNT\" -gt 1 ]; then CHANGES=$(git log --oneline --grep=\"^checkpoint:\" | head -10 | cut -d' ' -f2- | paste -sd ';' -); MSG=$(claude -p \"Create a single conventional commit message that summarizes these checkpoint changes: $CHANGES. Format: 'type(scope): description' followed by bullet points. Be concise and professional.\" 2>/dev/null | head -5 || echo \"feat: implement changes from checkpoints\"); FIRST_CHECKPOINT=$(git log --grep=\"^checkpoint:\" --format=\"%H\" | tail -1); if [ -n \"$FIRST_CHECKPOINT\" ]; then git reset --soft \"$FIRST_CHECKPOINT~1\" && git commit -m \"$MSG\" 2>/dev/null || true; fi; fi; rm -f \"$LOCKFILE\"; fi; fi"],
      "timeout": 45000
    },
    "preCompact": {
      "command": "bash", 
      "args": ["-c", "if [ -d .git ]; then LOCKFILE=\"/tmp/claude_compact_lock_$$\"; if ! [ -f \"$LOCKFILE\" ]; then touch \"$LOCKFILE\"; CHECKPOINT_COUNT=$(git log --oneline --grep=\"^checkpoint:\" | head -20 | wc -l); if [ \"$CHECKPOINT_COUNT\" -gt 0 ]; then CHANGES=$(git log --oneline --grep=\"^checkpoint:\" | head -15 | cut -d' ' -f2- | paste -sd ';' -); MSG=$(claude -p \"Create a conventional commit message for these checkpoint changes: $CHANGES. Format: 'type(scope): description' with bullet points. Be professional and concise.\" 2>/dev/null | head -5 || echo \"chore: auto-squash checkpoint commits\"); FIRST_CHECKPOINT=$(git log --grep=\"^checkpoint:\" --format=\"%H\" | tail -1); if [ -n \"$FIRST_CHECKPOINT\" ]; then git reset --soft \"$FIRST_CHECKPOINT~1\" && git commit -m \"$MSG\" 2>/dev/null || true; fi; fi; rm -f \"$LOCKFILE\"; fi; fi"],
      "timeout": 75000
    }
  }
}

3. Verify installation:

claude /hooks  # Should show 4 configured hooks
git status     # Make sure you're in a git repository

Test It

# Make any change to a file, then check git log
echo "// test" >> yourfile.js
git log --oneline -5  # You should see a checkpoint commit

💡 See It In Action

# You ask Claude to add a login form
claude "Add a login component to my React app"

# As Claude works, you see:
✅ checkpoint: create LoginForm component structure - 14:25
✅ checkpoint: add email and password input fields - 14:26  
✅ checkpoint: implement form validation logic - 14:27
✅ checkpoint: add submit handler and error states - 14:28

# When task completes, auto-squashed to:
✅ feat(auth): implement login component with validation
   - Create LoginForm component structure
   - Add email and password input fields
   - Implement form validation logic
   - Add submit handler and error states

That's it. You focus on building. The system handles professional git history automatically.


💡 How It Works

What Each Hook Does

  • PreToolUse: Auto-formats your code before Claude changes it
  • PostToolUse: Creates descriptive checkpoint commits after every change
  • Stop: Squashes checkpoints into clean task commits when Claude finishes
  • PreCompact: Cleans up any remaining checkpoints before memory clears

✨ Benefits

Never Lose Work: Every change immediately committed with descriptive messages Professional Git History: Clean conventional commits without manual effort
Better Debugging: Detailed record of exactly what changed when Improved Code Reviews: Meaningful commit messages and logical groupings Team Consistency: Automatic conventional commit format across all developers


🌿 Recommended Git Workflow

This system transforms your git practices into a professional, AI-enhanced workflow:

Branch-Per-Feature Development

# Start each new feature in its own branch
git checkout -b feature/user-authentication
git checkout -b fix/login-validation  
git checkout -b refactor/api-endpoints

Let the Automation Work

# Ask Claude to implement your feature
claude "Add JWT authentication to the login system"

# The hooks automatically create:
✅ checkpoint: create JWT utility functions - 14:25
✅ checkpoint: add token validation middleware - 14:26  
✅ checkpoint: implement login endpoint with JWT - 14:27
✅ checkpoint: add protected route guards - 14:28

# When task completes, auto-squashed to:
✅ feat(auth): implement JWT authentication system
   - Create JWT utility functions
   - Add token validation middleware  
   - Implement login endpoint with JWT
   - Add protected route guards

Professional Team Workflow

# Create PR with perfect commit history
git push origin feature/user-authentication

# Review shows:
# 1. Clean conventional commits (what was built)
# 2. Detailed checkpoint history (how it was built)
# 3. Zero manual commit management required

# Merge to main with confidence
git checkout main && git merge feature/user-authentication

Why This Workflow is Superior

🤖 AI-Enhanced Development

  • Claude works faster when it doesn't think about git management
  • Every change preserved automatically - experiment fearlessly
  • Perfect development narrative captured in each branch

👥 Team Collaboration

  • Consistent commit quality across all team members
  • Detailed audit trail for complex features
  • Code reviews focus on logic, not commit messages

🚀 Professional Output

  • Enterprise-quality git history without manual effort
  • Perfect conventional commits for automated tooling
  • Clean main branch ready for production deployment

💡 Development Flow

  • Zero cognitive overhead for git management
  • Focus entirely on feature development
  • Automatic documentation of decision-making process

🌟 The Future: Full MindPalace

This git automation is just the foundation. Coming soon:

🧠 Memory Reconstruction

Claude automatically rebuilds complete project context when memory resets - never explain your codebase again.

📋 Multi-Source Intelligence

Integrates PRD documents, TaskMaster, documentation, and issue tracking for comprehensive project awareness.

🔧 Modular Context System

Choose exactly the context depth you need - from basic git to full architectural understanding.

Read the full vision →


🛟 Troubleshooting

Hooks not working?

which claude        # Make sure claude command exists
git status         # Verify you're in a git repo
claude /hooks      # Check hooks are configured

No commit messages?

  • Ensure the claude command responds to -p flag
  • Check /tmp directory is writable
  • Verify git user.name and user.email are set

Duplicate commits?

  • Check if multiple Claude Code instances are running
  • The system has lockfile protection, but concurrent execution can cause issues

📄 More Documentation


Start building your MindPalace today. Transform your development workflow with intelligent, automatic git management.

Never write another commit message manually. 🧠✨