Wiring Verification
Wiring Verification
When building infrastructure components, ensure they're actually invoked in the execution path.
Pattern
Every module needs a clear entry point. Dead code is worse than no code - it creates maintenance burden and false confidence.
The Four-Step Wiring Check
Before marking infrastructure "done", verify:
Entry Point Exists: How does user action trigger this code?
Call Graph Traced: Can you follow the path from entry to execution?
Integration Tested: Does an end-to-end test exercise this path?
No Dead Code: Is every built component actually reachable?
DO
Verify Entry Points
# 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" .
Trace Call Graphs
# 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)
Test End-to-End
# 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
Document Wiring
## 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`
DON'T
Build Without Wiring
# 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)
Create Parallel Routing
# 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
Assume Imports Work
# 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')"
Skip Integration Tests
# 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
Common Wiring Gaps
Hook Not Registered
// .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 Not Executable
# Script exists but can't execute
-rw-r--r-- scripts/orchestrate.py
# Fix: Make executable
chmod +x scripts/orchestrate.py
Module Not Importable
# 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))
Router Has No Dispatch Path
# 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]
Wiring Checklist
Before marking infrastructure "complete":
Entry point identified and tested (hook/skill/CLI)
Call graph documented (entry → module execution)
Integration test exercises full path
No orphaned modules (everything imported/called)
Registration complete (settings.json/skill-rules.json)
Permissions correct (scripts executable)
Import paths verified (manual import test passes)
Real-World Examples
Example 1: DAG Orchestration (This Session)
What was built:
opc/orchestration/orchestration_layer.py (500+ lines)
opc/orchestration/dag/ (DAG builder, validator, executor)
18 agent type definitions
Sophisticated routing logic
Wiring gap:
No hook calls orchestration_layer.py
No script imports the DAG modules
Agent routing returns hardcoded "general-purpose"
Result: 100% dead code
Fix:
Create PreToolUse hook for Task tool
Hook calls scripts/orchestrate.py
Script imports and calls orchestration_layer.dispatch()
Dispatch uses AGENT_MAP to route to actual agents
Integration test: Submit Task → verify correct agent type used
Example 2: Artifact Index (Previous Session)
What was built:
SQLite database schema
Indexing logic
Query functions
Wiring gap:
No hook triggered indexing
Files created but never indexed
Fix:
PostToolUse hook on Write tool
Hook calls indexing script immediately
Integration test: Write file → verify indexed
Detection Strategy
Grep for Orphans
# Find Python modules
find . -name "*.py" -type f
# Check if each is imported
for file in $(find . -name "*.py"); do
module=$(basename $file .py)
grep -r "from.*$module import\|import.*$module" . || echo "ORPHAN: $file"
done
Check Hook Registration
# List all hooks in .claude/hooks/
ls .claude/hooks/*.sh
# Check each is registered
for hook in $(ls .claude/hooks/*.sh); do
basename_hook=$(basename $hook)
grep -q "$basename_hook" .claude/settings.json || echo "UNREGISTERED: $hook"
done
Verify Script Execution
# Find all Python scripts
find scripts/ -name "*.py"
# Test each can be imported
for script in $(find scripts/ -name "*.py"); do
uv run python -c "import sys; sys.path.insert(0, 'scripts'); import $(basename $script .py)" 2>/dev/null || echo "IMPORT FAIL: $script"
done
Source
This session: DAG orchestration wiring gap - 500+ lines of dead code discovered
Previous sessions: Artifact Index, LMStudio integration - wiring added after initial builddon't have the plugin yet? install it then click "run inline in claude" again.
added explicit decision points for common wiring failures, structured output contract with data formats and file locations, documented outcome signals with testability criteria, added edge cases like multiple routers and permission issues, preserved original four-step procedure faithfully.
wiring verification ensures that infrastructure code you build is actually called during execution. dead code creates maintenance burden and false confidence. this skill walks through the four-step check: entry point exists, call graph is traceable, integration test covers the path, and no component is orphaned. use this before marking any infrastructure "done".
.claude/settings.json, .claude/skill-rules.jsonuv or standard python toolingpytest (or equivalent)identify entry points: determine how user action or system event triggers code execution. check for hook registration in .claude/settings.json, skill activation in .claude/skill-rules.json, CLI entry points, or scheduled tasks. output: documented list of all potential entry points with file paths and line numbers.
trace the call graph: map the full path from entry point to module execution. start at the hook/script/CLI and follow imports and function calls downstream. document each layer (hook shell script → typescript/python wrapper → core module → business logic). output: call graph diagram or ascii chain showing entry → intermediate layers → final execution.
run end-to-end test: execute an integration test that simulates real user action and verifies the full path fires. do not rely on unit tests alone. for example, if code runs on Task tool use, echo a task json payload and verify the hook executes. output: test runs without error, logs show each layer was invoked.
scan for orphaned code: find all modules, scripts, and functions in the codebase. for each one, verify it is imported or called somewhere upstream. grep for imports, check hook registrations, trace function references. output: list of files/functions that are not reachable from any entry point.
verify registration and permissions: confirm hooks are registered in config files, scripts are executable (check chmod), and python import paths resolve. run manual import tests: python -c "from module import function". output: all registration checks pass, all imports resolve, all scripts are +x executable.
document wiring in a structured format: record entry point name, registration location, call path (with file names and line numbers), and integration test file. output: wiring documentation block that another developer can use to understand the flow in 30 seconds.
chmod +x scripts/name.sh or chmod +x scripts/name.py and re-test. verify file permissions show +x in ls -la output.wiring verification produces:
.claude/hooks/pre-tool-use.sh (line 12) → scripts/orchestrate.py (line 1) → orchestration_layer.py dispatch function.tests/integration/task_orchestration_test.py). test must pass and logs must show entry point was triggered.python -c "from module import ..." for each imported module, showing all imports resolve.all output is text or markdown, suitable for commit to repo.
you know wiring verification succeeded when:
if any of these fails, the wiring is incomplete. do not ship.
wiring checklist template
before marking infrastructure complete, verify:
common wiring gaps to catch
attribution
original skill by parcadei. enriched to follow implexa standards with explicit decision points, edge cases, and output contracts.