agentleFS
formkitformkit/auto-animate/.dmux-hooks/CLAUDE.md

auto-animate

CLAUDE.md14k starsChanged 4 months agoMITView on GitHub

Auto-generated documentation for AI agents This document contains everything an AI agent needs to create, modify, and understand dmux hooks. It is automatically generated from the dmux source code and embedded in the binary. You are editing hooks for dmux, a tmux pane manager that creates AI-powered development workflows. Each pane runs in its own git worktree with an AI agent (Claude Code or opencode). Create executable bash scripts in .dmux-hooks/ that run automatically at key lifecycle events. Interactive hooks…

  • Reads credentials
  • Installs packages
  • Sends data out
  • Commits and pushes

We split this CLAUDE.md into the rules it gives an agent

11 rules. About 0 are common, 6 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Create executable bash scripts in .dmux-hooks/ that run automatically at key lifecycle events.

    line 13
  2. Very specific:

    Add shebang: Start with #!/bin/bash

    line 19
  3. Distinctive:

    Environment-based: All context passed via environment variables

    line 27
  4. Very specific:

    Clean up temp files: Remove files in /tmp/

    line 256
  5. Distinctive:

    Test before committing: Run hooks manually with mock env vars

    line 257
  6. Distinctive:

    Before creating hooks, analyze these files in the project:

    line 292
  7. Distinctive:

    If a hook isn't working:

    line 365
  8. Very specific:

    Check permissions: Should show x in rwxr-xr-x

    line 368
  9. Distinctive:

    Simplify: Remove complex parts, test basic version

    line 372
  10. Distinctive:

    When creating a new hook:

    line 387
  11. Very specific:

    Examples: Check .dmux-hooks/examples/ directory

    line 404

≈ “Common” is an estimate: at least 1 in 5 of the 25,680 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

dmux Hooks System - Agent Reference

Auto-generated documentation for AI agents

This document contains everything an AI agent needs to create, modify, and understand dmux hooks. It is automatically generated from the dmux source code and embedded in the binary.

What You're Working On

You are editing hooks for dmux, a tmux pane manager that creates AI-powered development workflows. Each pane runs in its own git worktree with an AI agent (Claude Code or opencode).

Your Goal

Create executable bash scripts in .dmux-hooks/ that run automatically at key lifecycle events.

Quick Start

  1. Create a hook file: touch .dmux-hooks/worktree_created
  2. Make it executable: chmod +x .dmux-hooks/worktree_created
  3. Add shebang: Start with #!/bin/bash
  4. Use environment variables: Access $DMUX_ROOT, $DMUX_WORKTREE_PATH, etc.
  5. Test it: Set env vars manually and run the script

Hook Execution Model

  • Non-blocking: Hooks run in background (detached processes)
  • Silent failures: Hook errors are logged but don't stop dmux
  • Environment-based: All context passed via environment variables
  • Version controlled: Hooks in .dmux-hooks/ are shared with team
  • Priority resolution: .dmux-hooks/ → .dmux/hooks/ → ~/.dmux/hooks/

Available Hooks

Pane Lifecycle Hooks

HookWhenCommon Use Cases
before_pane_createBefore pane creationValidation, notifications, pre-flight checks
pane_createdAfter pane, before worktreeConfigure tmux settings, prepare environment
worktree_createdAfter full setupInstall deps, copy configs, setup git
before_pane_closeBefore closingSave state, backup uncommitted work
pane_closedAfter closedCleanup resources, analytics, notifications

Worktree Lifecycle Hooks

HookWhenCommon Use Cases
before_worktree_removeBefore worktree removalArchive worktree, save artifacts
worktree_removedAfter worktree removedCleanup external references

Merge Lifecycle Hooks

HookWhenCommon Use Cases
pre_mergeBefore merge operationRun final tests, create backups
post_mergeAfter successful mergeDeploy, close issues, notify team

Interactive Hooks (with HTTP callbacks)

HookWhenCommon Use Cases
run_testWhen tests triggeredRun test suite, report status via HTTP
run_devWhen dev server triggeredStart dev server, create tunnel, report URL

Environment Variables

Always Available

DMUX_ROOT="/path/to/project"           # Project root directory
DMUX_SERVER_PORT="3142"                # HTTP server port

Pane Context (most hooks)

DMUX_PANE_ID="dmux-1234567890"         # dmux pane identifier
DMUX_SLUG="fix-auth-bug"               # Branch/worktree name
DMUX_PROMPT="Fix authentication bug"   # User's prompt
DMUX_AGENT="claude"                    # Agent type (claude|opencode)
DMUX_TMUX_PANE_ID="%38"                # tmux pane ID

Worktree Context

DMUX_WORKTREE_PATH="/path/.dmux/worktrees/fix-auth-bug"
DMUX_BRANCH="fix-auth-bug"             # Same as slug

Merge Context

DMUX_TARGET_BRANCH="main"              # Branch being merged into

HTTP Callback API

Interactive hooks (run_test and run_dev) can update dmux UI via HTTP.

Update Test Status

curl -X PUT "http://localhost:$DMUX_SERVER_PORT/api/panes/$DMUX_PANE_ID/test"   -H "Content-Type: application/json"   -d '{"status": "running", "output": "optional test output"}'

# Status values: "running" | "passed" | "failed"

Update Dev Server

curl -X PUT "http://localhost:$DMUX_SERVER_PORT/api/panes/$DMUX_PANE_ID/dev"   -H "Content-Type: application/json"   -d '{"status": "running", "url": "http://localhost:3000"}'

# Status values: "running" | "stopped"
# url: Can be localhost or tunnel URL (ngrok, cloudflared, etc.)

Common Patterns

Pattern 1: Install Dependencies

#!/bin/bash
# .dmux-hooks/worktree_created

cd "$DMUX_WORKTREE_PATH"

if [ -f "pnpm-lock.yaml" ]; then
  pnpm install --prefer-offline &
elif [ -f "package-lock.json" ]; then
  npm install &
elif [ -f "yarn.lock" ]; then
  yarn install &
elif [ -f "Gemfile" ]; then
  bundle install &
elif [ -f "requirements.txt" ]; then
  pip install -r requirements.txt &
elif [ -f "Cargo.toml" ]; then
  cargo build &
fi

Pattern 2: Copy Configuration

#!/bin/bash
# .dmux-hooks/worktree_created

# Copy environment file
if [ -f "$DMUX_ROOT/.env.local" ]; then
  cp "$DMUX_ROOT/.env.local" "$DMUX_WORKTREE_PATH/.env.local"
fi

# Copy other config files
for file in .env.development .npmrc .yarnrc; do
  if [ -f "$DMUX_ROOT/$file" ]; then
    cp "$DMUX_ROOT/$file" "$DMUX_WORKTREE_PATH/$file"
  fi
done

Pattern 3: Run Tests with Status Updates

#!/bin/bash
# .dmux-hooks/run_test

set -e
cd "$DMUX_WORKTREE_PATH"
API="http://localhost:$DMUX_SERVER_PORT/api/panes/$DMUX_PANE_ID/test"

# Update: starting
curl -s -X PUT "$API" -H "Content-Type: application/json"   -d '{"status": "running"}' > /dev/null

# Run tests and capture output
OUTPUT_FILE="/tmp/dmux-test-$DMUX_PANE_ID.txt"
if pnpm test > "$OUTPUT_FILE" 2>&1; then
  STATUS="passed"
else
  STATUS="failed"
fi

# Get output (truncate if too long)
OUTPUT=$(head -c 5000 "$OUTPUT_FILE")

# Update: complete
curl -s -X PUT "$API" -H "Content-Type: application/json"   -d "$(jq -n --arg status "$STATUS" --arg output "$OUTPUT"     '{status: $status, output: $output}')" > /dev/null

rm -f "$OUTPUT_FILE"

Pattern 4: Dev Server with Tunnel

#!/bin/bash
# .dmux-hooks/run_dev

set -e
cd "$DMUX_WORKTREE_PATH"
API="http://localhost:$DMUX_SERVER_PORT/api/panes/$DMUX_PANE_ID/dev"

# Start dev server in background
LOG_FILE="/tmp/dmux-dev-$DMUX_PANE_ID.log"
pnpm dev > "$LOG_FILE" 2>&1 &
DEV_PID=$!

# Wait for server to start
sleep 5

# Detect port from logs
PORT=$(grep -oP 'localhost:Kd+' "$LOG_FILE" | head -1)
[ -z "$PORT" ] && PORT=3000

# Optional: Create tunnel with cloudflared
if command -v cloudflared &> /dev/null; then
  TUNNEL=$(cloudflared tunnel --url "http://localhost:$PORT" 2>&1 |     grep -oP 'https://[a-z0-9-]+.trycloudflare.com' | head -1)
  URL="${TUNNEL:-http://localhost:$PORT}"
else
  URL="http://localhost:$PORT"
fi

# Report status
curl -s -X PUT "$API" -H "Content-Type: application/json"   -d "{"status": "running", "url": "$URL"}" > /dev/null

echo "[Hook] Dev server running at $URL (PID: $DEV_PID)"

Pattern 5: Post-Merge Deployment

#!/bin/bash
# .dmux-hooks/post_merge

set -e
cd "$DMUX_ROOT"

# Only deploy from main/master
if [ "$DMUX_TARGET_BRANCH" != "main" ] && [ "$DMUX_TARGET_BRANCH" != "master" ]; then
  exit 0
fi

# Push to remote
git push origin "$DMUX_TARGET_BRANCH"

# Trigger deployment (example: Vercel)
if [ -n "$VERCEL_TOKEN" ]; then
  curl -s -X POST "https://api.vercel.com/v1/deployments"     -H "Authorization: Bearer $VERCEL_TOKEN"     -H "Content-Type: application/json"     -d '{"name": "my-project"}' > /dev/null
fi

# Close GitHub issue if prompt contains #123
ISSUE=$(echo "$DMUX_PROMPT" | grep -oP '#Kd+' | head -1)
if [ -n "$ISSUE" ] && command -v gh &> /dev/null; then
  gh issue close "$ISSUE"     -c "Resolved in $DMUX_SLUG, merged to $DMUX_TARGET_BRANCH"     2>/dev/null || true
fi

Best Practices

  1. Always start with shebang: #!/bin/bash
  2. Set error handling: set -e (exit on error)
  3. Make executable: chmod +x .dmux-hooks/hook_name
  4. Background long operations: Append & to avoid blocking
  5. Check for required tools: command -v tool &> /dev/null
  6. Log for debugging: echo "[Hook] message" >> "$DMUX_ROOT/.dmux/hooks.log"
  7. Handle missing vars gracefully: [ -z "$VAR" ] && exit 0
  8. Use silent curl: curl -s to avoid noise in logs
  9. Clean up temp files: Remove files in /tmp/
  10. Test before committing: Run hooks manually with mock env vars

Testing Hooks

Manual Testing

# 1. Set environment variables
export DMUX_ROOT="$(pwd)"
export DMUX_PANE_ID="test-pane"
export DMUX_SLUG="test-branch"
export DMUX_WORKTREE_PATH="$(pwd)"
export DMUX_SERVER_PORT="3142"
export DMUX_AGENT="claude"
export DMUX_PROMPT="Test prompt"

# 2. Run hook directly
./.dmux-hooks/worktree_created

# 3. Check exit code
echo $?  # Should be 0 for success

Syntax Check

# Check for syntax errors without running
bash -n ./.dmux-hooks/worktree_created

Shellcheck (if available)

shellcheck ./.dmux-hooks/worktree_created

Project Context Analysis

Before creating hooks, analyze these files in the project:

Package Manager Detection

# Check which package manager is used
if [ -f "pnpm-lock.yaml" ]; then
  # Use: pnpm install, pnpm test, pnpm dev
elif [ -f "package-lock.json" ]; then
  # Use: npm install, npm test, npm run dev
elif [ -f "yarn.lock" ]; then
  # Use: yarn install, yarn test, yarn dev
fi

Test Command Discovery

# Read package.json to find test command
cat package.json | grep '"test"'
# Or with jq:
jq -r '.scripts.test' package.json

Dev Command Discovery

# Read package.json to find dev command
cat package.json | grep '"dev"'
# Or with jq:
jq -r '.scripts.dev' package.json

Environment Variables

# Check for .env files to copy
ls -la | grep '.env'

Build System

# Detect build system
if [ -f "vite.config.ts" ]; then
  # Vite project
elif [ -f "next.config.js" ]; then
  # Next.js project
elif [ -f "nuxt.config.ts" ]; then
  # Nuxt project
fi

Common Mistakes to Avoid

❌ Blocking operations: sleep 60 (blocks dmux) ✅ Background long tasks: slow_operation &

❌ Hardcoded paths: /Users/me/project ✅ Use variables: "$DMUX_ROOT"

❌ Assuming tools exist: pnpm install ✅ Check first: command -v pnpm && pnpm install

❌ No error handling: Script fails silently ✅ Set error mode: set -e or check exit codes

❌ Forgetting executable bit: Hook won't run ✅ Make executable: chmod +x

❌ Noisy output: Clutters dmux logs ✅ Silent operations: curl -s, > /dev/null 2>&1

❌ Not testing: Deploy and hope ✅ Test manually: Run with mock env vars first

Debugging

If a hook isn't working:

  1. Check if file exists: ls -la .dmux-hooks/
  2. Check permissions: Should show x in rwxr-xr-x
  3. Check syntax: bash -n .dmux-hooks/hook_name
  4. Test manually: Set env vars and run
  5. Check logs: dmux logs to stderr with [Hooks] prefix
  6. Simplify: Remove complex parts, test basic version
  7. Check tool availability: command -v required_tool

Debug Mode

#!/bin/bash
# Add to top of hook for debugging
set -x  # Print each command before executing
set -e  # Exit on error

# Your hook logic here

Summary Checklist

When creating a new hook:

  • Create file in .dmux-hooks/
  • Add shebang: #!/bin/bash
  • Make executable: chmod +x
  • Add set -e for error handling
  • Use environment variables (never hardcode paths)
  • Background long operations with &
  • Check for required tools before using
  • Test manually with mock env vars
  • Add comments explaining what it does
  • Commit to version control

Getting Help

  • Full documentation: See HOOKS.md in project root
  • Claude-specific tips: See CLAUDE.md in .dmux-hooks/
  • Examples: Check .dmux-hooks/examples/ directory
  • dmux API: See API.md for REST endpoints

This documentation was auto-generated from dmux source code. Version: 2025-12-14

Download now (ZIP)

Trending

Steady: 0 new projects took it in the last 4 weeks, none the 4 weeks before.thin data

Week of Aug 30: 0 new projectsWeek of Sep 6: 0 new projectsWeek of Sep 13: 0 new projectsWeek of Sep 20: 0 new projectsWeek of Sep 27: 0 new projectsWeek of Oct 4: 0 new projectsWeek of Oct 11: 0 new projectsWeek of Oct 18: 0 new projects
Aug 2026Sep 2026Oct 2026
New projects taking a version of this file each week, over the 8 weeks our latest run read: only 0 in all, so this is a hint, not a trend.

Who's talking about formkit/auto-animate

The biggest 5 of 60 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 60

Talked about on GitHub, Bluesky, YouTube, Hacker News and Stack Overflow (60 times).

On GitHub · 50

45 more on GitHub

On Bluesky · 5

On YouTube · 2

On Stack Overflow · 1

  • Other versions1 project uses a version of this.

    Word for word · 1

    1. formkit/formkit★ 4.8k100% same

    Edited · 0

    None found.

    Wrote their own version · 0

    None found.

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repositoryOne other file it gives its agents.

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.