trace-claude-code
Automatically trace Claude Code conversations to Braintrust for observability. Captures sessions, conversation turns, and tool calls as hierarchical traces.
Wiring Verification
$ npx -y skills add parcadei/Continuous-Claude-v3 --skill wiring --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/wiringContext preview
The summary Claude sees to decide when to auto-load this skill.
Wiring Verification
name: wiring description: Wiring Verification user-invocable: false
When building infrastructure components, ensure they're actually invoked in the execution path.
Every module needs a clear entry point. Dead code is worse than no code - it creates maintenance burden and false confidence.
Before marking infrastructure "done", verify:
1. **Entry Point Exists**: How does user action trigger this code? 2. **Call Graph Traced**: Can you follow the path from entry to execution? 3. **Integration Tested**: Does an end-to-end test exercise this path? 4. **No Dead Code**: Is every built component actually reachable?
# Hook registered? grep -r "orchestration" .claude/settings.json # Skill activated? grep -r "skill-name" .claude/skill-rules.json # Script executable? ls -la scripts/orchestrate.py # Module imported? grep -r "from orchestration_layer import" .
# Entry point (hook)
.claude/hooks/pre-tool-use.sh
↓
# Shell wrapper calls TypeScript
npx tsx pre-tool-use.ts
↓
# TypeScript calls Python script
spawn('scripts/orchestrate.py')
↓
# Script imports module
from orchestration_layer import dispatch
↓
# Module executes
dispatch(agent_type, task)# Don't just unit test the module
pytest tests/unit/orchestration_layer_test.py # NOT ENOUGH
# Test the full invocation path
echo '{"tool": "Task"}' | .claude/hooks/pre-tool-use.sh # VERIFY THIS WORKS## Wiring - **Entry Point**: PreToolUse hook on Task tool - **Registration**: `.claude/settings.json` line 45 - **Call Path**: hook → pre-tool-use.ts → scripts/orchestrate.py → orchestration_layer.py - **Test**: `tests/integration/task_orchestration_test.py`
# BAD: Created orchestration_layer.py with 500 lines # But nothing imports it or calls it # Result: Dead code, wasted effort # GOOD: Start with minimal wiring, then expand # 1. Create hook (10 lines) # 2. Test hook fires # 3. Add script (20 lines) # 4. Test script executes # 5. Add module logic (iterate)
# BAD: Agent router has dispatch logic # AND skill-rules.json has agent selection logic # AND hooks have agent filtering logic # Result: Three places to update, routing conflicts # GOOD: Single source of truth for routing # skill-rules.json activates skill → skill calls router → router dispatches
# BAD: Assume because you wrote the code, it's imported
from orchestration_layer import dispatch # Does this path exist?
# GOOD: Verify imports at integration test time
uv run python -c "from orchestration_layer import dispatch; print('OK')"# BAD: Only unit test pytest tests/unit/ # All pass, but nothing works end-to-end # GOOD: Integration test the wiring pytest tests/integration/ # Verify full call path
// .claude/settings.json - hook definition exists but not in hooks section
{
"hooks": {
"PreToolUse": [] // Empty! Your hook never fires
}
}**Fix**: Add hook registration:
{
"hooks": {
"PreToolUse": [{
"matcher": ["Task"],
"hooks": [{
"type": "command",
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/orchestration.sh"
}]
}]
}
}# Script exists but can't execute -rw-r--r-- scripts/orchestrate.py # Fix: Make executable chmod +x scripts/orchestrate.py
# Script tries to import but path is wrong from orchestration_layer import dispatch # ModuleNotFoundError # Fix: Add to Python path or use proper package structure sys.path.insert(0, str(Path(__file__).parent.parent))
# BAD: Router has beautiful mapping
AGENT_MAP = {
"implement": ImplementAgent,
"research": ResearchAgent,
# ... 18 agent types
}
# But no dispatch function uses the map
def route(task):
return "general-purpose" # Hardcoded! Map is dead code
# GOOD: Dispatch actually uses the map
def route(task):
agent_type = classify(task)
return AGENT_MAP[agent_type]Before marking infrastructure "complete":
**What was built:**
**Wiring gap:**
**Fix:** 1. Create PreToolUse hook for Task tool 2. Hook calls `scripts/orchestrate.py` 3. Script imports and calls `orchestration_layer.dispatch()` 4. Dispatch uses AGENT_MAP to route to actual agents 5. Integration test: Submit Task → verify correct agent type used
**What was built:**
**Wiring gap:**
**Fix:** 1. PostToolUse hook on Write tool 2. Hook calls indexing script immediately 3. Integration test: Write file → verify indexed
# Find Python modules find . -name "*.py" -type f # Check if each is imported for f
A persistent, learning, multi-agent development environment built on Claude Code Continuous Claude transforms Claude Code into a continuously learning system that maintains context across sessions, orchestrates specialized agents, and eliminates wasting
Repo: parcadei/Continuous-Claude-v3
Automatically trace Claude Code conversations to Braintrust for observability. Captures sessions, conversation turns, and tool calls as hierarchical traces.
Guide for integrating Agentica SDK with Claude Code CLI proxy
Reference guide for Agentica multi-agent infrastructure APIs