| name | ct-debug-skill |
| description | Debug and troubleshoot claude-threads, orchestrator, and agent issues |
| allowed-tools | Bash,Read,Grep,Glob |
| user-invocable | true |
| version | 1.0.0 |
Claude Threads Debug Skill
Diagnose and troubleshoot issues with claude-threads, orchestrator, threads, worktrees, and agent coordination.
When to Use
Activate this skill when:
- Threads are stuck, blocked, or not starting
- Orchestrator won't start or crashes
- Worktrees are orphaned or inconsistent
- Events aren't being delivered
- Database is corrupted or inconsistent
- Agents aren't coordinating properly
- PR lifecycle management isn't working
Quick Diagnostics
System Health Check
ct orchestrator status
ct api status
ct db check
ct thread list --all
ct worktree list
ct worktree reconcile
Thread Diagnostics
ct thread status <thread-id>
ct thread status <thread-id> --verbose
ct thread logs <thread-id> --tail 100
ct thread logs <thread-id> -f
ct thread list blocked
ct thread list running
Orchestrator Diagnostics
ps aux | grep -E "orchestrator|ct"
cat .claude-threads/logs/orchestrator.log | tail -100
ls -la .claude-threads/*.lock 2>/dev/null
rm -f .claude-threads/orchestrator.lock
Worktree Diagnostics
ct worktree list
ct worktree reconcile
ct worktree reconcile --fix
git worktree list
ct worktree status <worktree-id>
Base + Fork Diagnostics
sqlite3 .claude-threads/threads.db "SELECT * FROM pr_base_worktrees;"
sqlite3 .claude-threads/threads.db "SELECT * FROM pr_worktree_forks;"
ct worktree base-status <pr-number>
ct worktree list-forks <pr-number>
ls -la .claude-threads/worktrees/*.lock 2>/dev/null
Event Diagnostics
ct event list --limit 50
ct event list --type THREAD_FAILED --limit 20
ct event list --type ESCALATION_NEEDED --limit 20
ct event list --source <thread-id> --limit 20
ct event watch --types "FAILED,BLOCKED,ESCALATION"
Database Diagnostics
ls -la .claude-threads/threads.db
sqlite3 .claude-threads/threads.db "PRAGMA integrity_check;"
sqlite3 .claude-threads/threads.db "SELECT * FROM schema_migrations ORDER BY version DESC LIMIT 5;"
sqlite3 .claude-threads/threads.db "
SELECT 'threads' as table_name, COUNT(*) as count FROM threads
UNION ALL
SELECT 'events', COUNT(*) FROM events
UNION ALL
SELECT 'pr_watches', COUNT(*) FROM pr_watches
UNION ALL
SELECT 'pr_base_worktrees', COUNT(*) FROM pr_base_worktrees
UNION ALL
SELECT 'pr_worktree_forks', COUNT(*) FROM pr_worktree_forks;
"
sqlite3 .claude-threads/threads.db "
SELECT id, name, status, updated_at
FROM threads
WHERE status IN ('blocked', 'failed', 'error')
ORDER BY updated_at DESC;
"
API Diagnostics
curl -s http://localhost:31337/api/health | jq .
curl -s http://localhost:31337/api/status | jq .
curl -s -H "Authorization: Bearer $CT_API_TOKEN" \
http://localhost:31337/api/status | jq .
lsof -i :31337
PR Shepherd Diagnostics
ct pr list
ct pr status <pr-number>
ct pr comments <pr-number>
ct pr conflicts <pr-number>
cat .claude-threads/logs/pr-shepherd.log | tail -100
Common Issues and Fixes
Issue: Thread Stuck in "running" but not executing
Symptoms:
- Thread shows "running" in
ct thread list
- No activity in logs
- Process may have crashed
Diagnosis:
ct thread status <thread-id> --verbose
ps aux | grep <thread-id>
cat .claude-threads/logs/thread-<thread-id>.log | tail -50
Fix:
ct thread stop <thread-id> --force
ct thread start <thread-id>
Issue: Orchestrator won't start
Symptoms:
ct orchestrator start hangs or fails
- "Already running" but no process
Diagnosis:
ls -la .claude-threads/orchestrator.lock
ps aux | grep orchestrator
Fix:
rm -f .claude-threads/orchestrator.lock
ct orchestrator start
Issue: Worktrees out of sync with database
Symptoms:
- Worktrees exist on disk but not in database (or vice versa)
- Fork operations fail
Diagnosis:
ct worktree reconcile
Fix:
ct worktree reconcile --fix
Issue: Fork merge-back fails
Symptoms:
ct worktree merge-back returns error
- Conflict during merge
Diagnosis:
cd $(ct worktree fork-path <fork-id>)
git status
git diff
Fix:
ct worktree remove-fork <fork-id> --force
ct worktree base-update <pr-number>
cd $(ct worktree base-path <pr-number>)
git merge --no-commit $(ct worktree fork-path <fork-id>)
git add .
git commit -m "Merge fork with manual conflict resolution"
ct worktree remove-fork <fork-id> --force
Issue: Events not being delivered
Symptoms:
- Agent publishes event but listener never receives
- Events stuck in queue
Diagnosis:
ct event list --limit 50
sqlite3 .claude-threads/threads.db "
SELECT type, COUNT(*), MAX(created_at)
FROM events
GROUP BY type
ORDER BY MAX(created_at) DESC;
"
Fix:
cat .claude-threads/config.yaml | grep -A5 events
ct event process
Issue: Database locked
Symptoms:
- "database is locked" errors
- Operations fail intermittently
Diagnosis:
lsof .claude-threads/threads.db
Fix:
ct orchestrator stop
ct thread list running | xargs -I {} ct thread stop {}
sleep 5
ct orchestrator start
Issue: API returns 401/403
Symptoms:
- Remote connections fail with auth errors
- "Unauthorized" responses
Diagnosis:
grep api_token .claude-threads/config.yaml
echo $CT_API_TOKEN
echo $N8N_API_TOKEN
curl -v -H "Authorization: Bearer $CT_API_TOKEN" \
http://localhost:31337/api/health
Fix:
ct remote disconnect
ct remote connect localhost:31337 --token $CT_API_TOKEN
Advanced Debugging
Enable Verbose Logging
export CT_DEBUG=1
export CT_LOG_LEVEL=debug
ct orchestrator restart
Trace Event Flow
ct event watch
ct spawn test-thread --template developer.md
Database Queries
sqlite3 .claude-threads/threads.db "
SELECT t.id, t.name, t.status, t.created_at
FROM threads t
WHERE t.context LIKE '%\"pr_number\":123%'
ORDER BY t.created_at DESC;
"
sqlite3 .claude-threads/threads.db "
SELECT id, name, status, error_message, updated_at
FROM threads
WHERE status = 'failed'
ORDER BY updated_at DESC
LIMIT 10;
"
sqlite3 .claude-threads/threads.db "
SELECT e.type, e.source_thread_id, e.created_at,
substr(e.data, 1, 100) as data_preview
FROM events e
ORDER BY e.created_at DESC
LIMIT 20;
"
Process Tracing
ps aux | grep -E "ct|claude|orchestrator" | grep -v grep
pstree -p $(pgrep -f orchestrator)
lsof -p $(pgrep -f orchestrator)
Git State Recovery
cd .claude-threads/worktrees/<worktree-id>
git fsck
git gc --prune=now
git worktree remove .claude-threads/worktrees/<worktree-id> --force
ct worktree cleanup
Cleanup Commands
ct orchestrator stop
ct api stop
ct thread list --all | xargs -I {} ct thread delete {}
ct worktree cleanup --force
ct worktree reconcile --fix
rm .claude-threads/threads.db
ct db migrate
rm -rf .claude-threads
ct init
Documentation