| name | htmlgraph-tracker |
| description | HtmlGraph session tracking and documentation skill. Activated automatically at session start to ensure proper activity attribution, feature awareness, and documentation habits. Use when working with HtmlGraph-enabled projects, when drift warnings appear, or when the user asks about tracking features or sessions. |
HtmlGraph Tracker Skill
Use this skill when HtmlGraph is tracking the session to ensure proper activity attribution and documentation. Activate this skill at session start via the SessionStart hook.
š REQUIRED READING
ā READ ../../../AGENTS.md FOR COMPLETE SDK DOCUMENTATION
The root AGENTS.md file contains:
- ā Python SDK Quick Start - Installation, initialization, basic operations
- ā
Deployment Instructions - Using
deploy-all.shscript - ā API & CLI Reference - Alternative interfaces
- ā Best Practices - Patterns for AI agents
- ā Complete Workflow Examples - End-to-end scenarios
This file (SKILL.md) contains Claude Code-specific instructions only.
For SDK usage, deployment, and general agent workflows ā USE AGENTS.md
When to Activate This Skill
- At the start of every session when HtmlGraph plugin is enabled
- When the user asks about tracking, features, or session management
- When drift detection warnings appear
- When the user mentions htmlgraph, features, sessions, or activity tracking
- When discussing work attribution or documentation
Trigger keywords: htmlgraph, feature tracking, session tracking, drift detection, activity log, work attribution, feature status, session management
Core Responsibilities
1. Use SDK, Not MCP Tools (CRITICAL)
IMPORTANT: For Claude Code, use the Python SDK directly instead of MCP tools.
Why SDK over MCP:
- ā No context bloat - MCP tool schemas consume precious tokens
- ā Runtime discovery - Explore all operations via Python introspection
- ā Type hints - See all available methods without schemas
- ā More powerful - Full programmatic access, not limited to 3 MCP tools
- ā Faster - Direct Python, no JSON-RPC overhead
The SDK provides access to ALL HtmlGraph operations without adding tool definitions to your context.
ABSOLUTE RULE: DO NOT use Read, Write, or Edit tools on .htmlgraph/ HTML files.
Use the SDK (or API/CLI for special cases) to ensure all HTML is validated through Pydantic + justhtml.
ā FORBIDDEN:
# NEVER DO THIS
Write('/path/to/.htmlgraph/features/feature-123.html', ...)
Edit('/path/to/.htmlgraph/sessions/session-456.html', ...)
with open('.htmlgraph/features/feature-123.html', 'w') as f:
f.write('<html>...</html>')
ā REQUIRED - Use SDK (BEST CHOICE FOR AI AGENTS):
from htmlgraph import SDK
sdk = SDK(agent="claude")
# Work with ANY collection (features, bugs, chores, spikes, epics, phases)
sdk.features # Features with builder support
sdk.bugs # Bug reports
sdk.chores # Maintenance tasks
sdk.spikes # Investigation spikes
sdk.epics # Large bodies of work
sdk.phases # Project phases
# Create features (fluent interface)
feature = sdk.features.create("Title") \
.set_priority("high") \
.add_steps(["Step 1", "Step 2"]) \
.save()
# Edit ANY collection (auto-saves)
with sdk.features.edit("feature-123") as f:
f.status = "done"
with sdk.bugs.edit("bug-001") as bug:
bug.status = "in-progress"
bug.priority = "critical"
# Vectorized batch updates (efficient!)
sdk.bugs.batch_update(
["bug-001", "bug-002", "bug-003"],
{"status": "done", "resolution": "fixed"}
)
# Query across collections
high_priority = sdk.features.where(status="todo", priority="high")
in_progress_bugs = sdk.bugs.where(status="in-progress")
# All collections have same interface
sdk.chores.mark_done(["chore-1", "chore-2"])
sdk.spikes.assign(["spike-1"], agent="claude")
Why SDK is best:
- ā 3-16x faster than CLI (no process startup)
- ā Type-safe with auto-complete
- ā Context managers (auto-save)
- ā Vectorized batch operations
- ā Works offline (no server needed)
- ā Supports ALL collections (features, bugs, chores, spikes, epics, etc.)
ā ALTERNATIVE - Use CLI (for one-off commands):
# CLI is slower (400ms startup per command) but convenient for one-off queries
uv run htmlgraph feature create/start/complete
uv run htmlgraph status
ā ļø AVOID - API/curl (use only for remote access):
# Requires server + network overhead, only use for remote access
curl -X PATCH localhost:8080/api/features/feat-123 -d '{"status": "done"}'
Why this matters:
- Direct file edits bypass Pydantic validation
- Bypass justhtml HTML generation (can create invalid HTML)
- Break the SQLite index sync
- Skip event logging and activity tracking
- Can corrupt graph structure and relationships
NO EXCEPTIONS: NEVER read, write, or edit .htmlgraph/ files directly.
Use the SDK for ALL operations including inspection:
# ā
CORRECT - Inspect sessions/events via SDK
from htmlgraph import SDK
from htmlgraph.session_manager import SessionManager
sdk = SDK(agent="claude-code")
sm = SessionManager()
# Get current session
session = sm.get_active_session(agent="claude-code")
# Get recent events (last 10)
recent = session.get_events(limit=10, offset=session.event_count - 10)
for evt in recent:
print(f"{evt['event_id']}: {evt['tool']} - {evt['summary']}")
# Query events by tool
bash_events = session.query_events(tool='Bash', limit=20)
# Query events by feature
feature_events = session.query_events(feature_id='feat-123')
# Get event statistics
stats = session.event_stats()
print(f"Total: {stats['total_events']}, Tools: {stats['tools_used']}")
ā FORBIDDEN - Reading files directly:
# NEVER DO THIS
with open('.htmlgraph/events/session-123.jsonl') as f:
events = [json.loads(line) for line in f]
# NEVER DO THIS
tail -10 .htmlgraph/events/session-123.jsonl
Documentation:
- Complete SDK guide:
docs/SDK_FOR_AI_AGENTS.md - Event inspection:
docs/SDK_EVENT_INSPECTION.md - Agent best practices:
docs/AGENTS.md
2. Feature Awareness (MANDATORY)
Always know which feature(s) are currently in progress:
- Check active features at session start: run
uv run htmlgraph status - Reference the current feature when discussing work
- Alert immediately if work drifts from the assigned feature
3. Step Completion (CRITICAL)
Mark each step complete IMMEDIATELY after finishing it:
- Use SDK to complete individual steps as you finish them
- Step 0 = first step, step 1 = second step (0-based indexing)
- Do NOT wait until all steps are done - mark each one as you finish
- See "How to Mark Steps Complete" section below for exact commands
4. Continuous Tracking (CRITICAL)
ABSOLUTE REQUIREMENT: Track ALL work in HtmlGraph.
HtmlGraph tracking is like Git commits - never do work without tracking it.
Update HtmlGraph immediately after completing each piece of work:
- ā Finished a step? ā Mark it complete in SDK
- ā Fixed a bug? ā Update bug status
- ā Discovered a decision? ā Document it in the feature
- ā Changed approach? ā Note it in activity log
- ā Completed a task? ā Mark feature/bug/chore as done
Why this matters:
- Attribution ensures work isn't lost across sessions
- Links between sessions and features preserve context
- Drift detection helps catch scope creep early
- Analytics show real progress, not guesses
The hooks track tool usage automatically, but YOU must:
- Start features before working (
uv run htmlgraph feature start <id>) - Mark steps complete as you finish them (use SDK)
- Complete features when done (
uv run htmlgraph feature complete <id>)
5. Activity Attribution
HtmlGraph automatically tracks tool usage. Action items:
- Use descriptive summaries in Bash
descriptionparameter - Reference feature IDs in commit messages
- Mention the feature context when starting new tasks
6. Documentation Habits
For every significant piece of work:
- Summarize what was done and why
- Note any decisions made and alternatives considered
- Record blockers or dependencies discovered
Working with Tracks, Specs, and Plans
What Are Tracks?
Tracks are high-level containers for multi-feature work (conductor-style planning):
- Track = Overall initiative with multiple related features
- Spec = Detailed specification with requirements and acceptance criteria
- Plan = Implementation plan with phases and estimated tasks
- Features = Individual work items linked to the track
When to create a track:
- Work involves 3+ related features
- Need high-level planning before implementation
- Multi-phase implementation
- Coordination across multiple sessions or agents
When to skip tracks:
- Single feature work
- Quick fixes or enhancements
- Direct implementation without planning phase
Creating Tracks with TrackBuilder (PRIMARY METHOD)
IMPORTANT: Use the TrackBuilder for deterministic track creation with minimal effort.
The TrackBuilder provides a fluent API that auto-generates IDs, timestamps, file paths, and HTML files.
from htmlgraph import SDK
sdk = SDK(agent="claude")
# Create complete track with spec and plan in one command
track = sdk.tracks.builder() \
.title("User Authentication System") \
.description("Implement OAuth 2.0 authentication with JWT") \
.priority("high") \
.with_spec(
overview="Add secure authentication with OAuth 2.0 support for Google and GitHub",
context="Current system has no authentication. Users need secure login with session management.",
requirements=[
("Implement OAuth 2.0 flow", "must-have"),
("Add JWT token management", "must-have"),
("Create user profile endpoint", "should-have"),
"Add password reset functionality" # Defaults to "must-have"
],
acceptance_criteria=[
("Users can log in with Google/GitHub", "OAuth integration test passes"),
"JWT tokens expire after 1 hour",
"Password reset emails sent within 5 minutes"
]
) \
.with_plan_phases([
("Phase 1: OAuth Setup", [
"Configure OAuth providers (1h)",
"Implement OAuth callback (2h)",
"Add state verification (1h)"
]),
("Phase 2: JWT Integration", [
"Create JWT signing logic (2h)",
"Add token refresh endpoint (1.5h)",
"Implement token validation middleware (2h)"
]),
("Phase 3: User Management", [
"Create user profile endpoint (3h)",
"Add password reset flow (4h)",
"Write integration tests (3h)"
])
]) \
.create()
# Output:
# ā Created track: track-20251221-220000
# - Spec with 4 requirements
# - Plan with 3 phases, 9 tasks
# Files created automatically:
# .htmlgraph/tracks/track-20251221-220000/index.html (track metadata)
# .htmlgraph/tracks/track-20251221-220000/spec.html (specification)
# .htmlgraph/tracks/track-20251221-220000/plan.html (implementation plan)
TrackBuilder Features:
- ā Auto-generates track IDs with timestamps
- ā Creates index.html, spec.html, plan.html automatically
- ā
Parses time estimates from task descriptions
"Task (2h)" - ā Validates requirements and acceptance criteria via Pydantic
- ā Fluent API with method chaining
- ā
Single
.create()call generates everything
Linking Features to Tracks
After creating a track, link features to it:
from htmlgraph import SDK
sdk = SDK(agent="claude")
# Get the track ID from the track you created
track_id = "track-20251221-220000"
# Create features and link to track
oauth_feature = sdk.features.create("OAuth Integration") \
.set_track(track_id) \
.set_priority("high") \
.add_steps([
"Configure OAuth providers",
"Implement OAuth callback",
"Add state verification"
]) \
.save()
jwt_feature = sdk.features.create("JWT Token Management") \
.set_track(track_id) \
.set_priority("high") \
.add_steps([
"Create JWT signing logic",
"Add token refresh endpoint",
"Implement validation middleware"
]) \
.save()
# Features are now linked to the track
# Query features by track:
track_features = sdk.features.where(track=track_id)
print(f"Track has {len(track_features)} features")
The track_id field:
- Links features to their parent track
- Enables track-level progress tracking
- Used for querying related features
- Automatically indexed for fast lookups
Track Workflow Example
Complete workflow from track creation to feature completion:
from htmlgraph import SDK
sdk = SDK(agent="claude")
# 1. Create track with spec and plan
track = sdk.tracks.builder() \
.title("API Rate Limiting") \
.description("Protect API endpoints from abuse") \
.priority("critical") \
.with_spec(
overview="Implement rate limiting to prevent API abuse",
context="Current API has no limits, vulnerable to DoS attacks",
requirements=[
("Implement token bucket algorithm", "must-have"),
("Add Redis for distributed limiting", "must-have"),
("Create rate limit middleware", "must-have")
],
acceptance_criteria=[
("100 requests/minute per API key", "Load test passes"),
"429 status code when limit exceeded"
]
) \
.with_plan_phases([
("Phase 1: Core", ["Token bucket (3h)", "Redis client (1h)"]),
("Phase 2: Integration", ["Middleware (2h)", "Error handling (1h)"]),
("Phase 3: Testing", ["Unit tests (2h)", "Load tests (3h)"])
]) \
.create()
# 2. Create features from plan phases
for phase_idx, (phase_name, tasks) in enumerate([
("Core Implementation", ["Implement token bucket", "Add Redis client"]),
("API Integration", ["Create middleware", "Add error handling"]),
("Testing & Validation", ["Write unit tests", "Run load tests"])
]):
feature = sdk.features.create(phase_name) \
.set_track(track.id) \
.set_priority("critical") \
.add_steps(tasks) \
.save()
print(f"ā Created feature {feature.id} for track {track.id}")
# 3. Work on features
# Start first feature
first_feature = sdk.features.where(track=track.id, status="todo")[0]
with sdk.features.edit(first_feature.id) as f:
f.status = "in-progress"
# ... do the work ...
# Mark steps complete as you finish them
with sdk.features.edit(first_feature.id) as f:
f.steps[0].completed = True
# Complete feature when done
with sdk.features.edit(first_feature.id) as f:
f.status = "done"
# 4. Track progress
track_features = sdk.features.where(track=track.id)
completed = len([f for f in track_features if f.status == "done"])
print(f"Track progress: {completed}/{len(track_features)} features complete")
TrackBuilder API Reference
Methods:
.title(str)- Set track title (REQUIRED).description(str)- Set description (optional).priority(str)- Set priority: "low", "medium", "high", "critical" (default: "medium").with_spec(...)- Add specification (optional)overview- High-level summarycontext- Background and current staterequirements- List of(description, priority)tuples or strings- Priorities: "must-have", "should-have", "nice-to-have"
acceptance_criteria- List of(description, test_case)tuples or strings
.with_plan_phases(list)- Add plan phases (optional)- Format:
[(phase_name, [task_descriptions]), ...] - Task estimates: Include
(Xh)in description, e.g., "Implement auth (3h)"
- Format:
.create()- Execute build and create all files (returns Track object)
Documentation:
- Quick start:
docs/TRACK_BUILDER_QUICK_START.md - Complete workflow:
docs/TRACK_WORKFLOW.md - Full proposal:
docs/AGENT_FRIENDLY_SDK.md
Pre-Work Validation Hook
NEW: HtmlGraph enforces the workflow via a PreToolUse validation hook that ensures code changes are always tracked.
How Validation Works
The validation hook runs BEFORE every tool execution and makes decisions based on your current work item:
VALIDATION RULES:
| Scenario | Tool | Action | Reason |
|---|---|---|---|
| Active Feature | Read | ā Allow | Exploration is always allowed |
| Active Feature | Write/Edit/Delete | ā Allow | Code changes match active feature |
| Active Spike | Read | ā Allow | Spikes permit exploration |
| Active Spike | Write/Edit/Delete | ā ļø Warn + Allow | Planning spike, code changes not tracked |
| Auto-Spike (session-init) | All | ā Allow | Planning phase, don't block |
| No Active Work | Read | ā Allow | Exploration without feature is OK |
| No Active Work | Write/Edit/Delete (1 file) | ā ļø Warn + Allow | Single-file changes often trivial |
| No Active Work | Write/Edit/Delete (3+ files) | ā Deny | Requires explicit feature creation |
| SDK Operations | All | ā Allow | Creating work items always allowed |
When Validation BLOCKS (Deny)
Validation DENIES code changes (Write/Edit/Delete) when ALL of these are true:
- ā No active feature, bug, or chore (no work item)
- ā Changes affect 3 or more files
- ā Not an auto-spike (session-init or transition)
- ā Not an SDK operation (e.g., creating features)
What you see:
PreToolUse Validation: Cannot proceed without active work item
- Reason: Multi-file changes (5 files) without tracked work item
- Action: Create a feature first with uv run htmlgraph feature create
Resolution: Create a feature using the feature decision framework, then try again.
When Validation WARNS (Allow with Warning)
Validation WARNS BUT ALLOWS when:
- ā ļø Single-file changes without active work item (likely trivial)
- ā ļø Active spike (planning-only, code changes won't be fully tracked)
- ā ļø Auto-spike (session initialization, inherent planning phase)
What you see:
PreToolUse Validation: Warning - activity may not be tracked
- File: src/config.py (1 file)
- Reason: Single-file change without active feature
- Option: Create feature if this is significant work
You can continue - but consider if the work deserves a feature.
Auto-Spike Integration
Auto-spikes are automatic planning spikes created during session initialization.
When the validation hook detects the start of a new session:
- ā
Creates an automatic spike (e.g.,
spike-session-init-abc123) - ā Marks it as planning-only (code changes permitted but not deeply tracked)
- ā Does NOT block any operations
- ā Allows exploration without forcing feature creation
Why auto-spikes?
- Captures early exploration work that doesn't fit a feature yet
- Avoids false positives from investigation activities
- Enables "think out loud" without rigid workflow
- Transitions to feature when scope becomes clear
Example auto-spike lifecycle:
Session Start
ā
Auto-spike created: spike-session-init-20251225
ā
Investigation/exploration work
ā
"This needs to be a feature" ā Create feature, link to spike
ā
Feature takes primary attribution
ā
Spike marked as resolved
Decision Framework for Code Changes
Use this framework to decide if you need a feature before making code changes:
User request or idea
āā Single file, <30 min? ā DIRECT CHANGE (validation warns, allows)
āā 3+ files? ā CREATE FEATURE (validation denies without feature)
āā New tests needed? ā CREATE FEATURE (validation blocks)
āā Multi-component impact? ā CREATE FEATURE (validation blocks)
āā Hard to revert? ā CREATE FEATURE (validation blocks)
āā Needs documentation? ā CREATE FEATURE (validation blocks)
āā Otherwise ā DIRECT CHANGE (validation warns, allows)
Key insight: Validation's deny threshold (3+ files) aligns with the feature decision threshold in CLAUDE.md.
Validation Scenarios (Examples)
Scenario 1: Working with Auto-Spike (Session Start)
Situation: You just started a new session. No features are active.
# Session starts ā auto-spike created automatically
# spike-session-init-20251225 is now active (auto-created)
# All of these work WITHOUT creating a feature:
- Read code files (exploration)
- Write to a single file (validation warns but allows)
- Create a feature (SDK operation, always allowed)
- Ask the user what to work on
Flow:
- ā Session starts
- ā Validation creates auto-spike for this session
- ā You explore and read code (no restrictions)
- ā You ask user what to work on
- ā User says: "Implement user authentication"
- ā
You create feature:
uv run htmlgraph feature create "User Authentication" - ā Feature becomes primary (replaces auto-spike attribution)
- ā You can now code freely
Result: Work is properly attributed to the feature, not the throwaway auto-spike.
Scenario 2: Multi-File Feature Implementation
Situation: User says "Build a user authentication system"
WITHOUT feature:
# Try to edit 5 files without creating a feature
uv run htmlgraph something that touches 5 files
# Validation DENIES:
# ā PreToolUse Validation: Cannot proceed without active work item
# Reason: Multi-file changes (5 files) without tracked work item
# Action: Create a feature first
WITH feature:
# Create the feature first
uv run htmlgraph feature create "User Authentication"
# ā feat-abc123 created and marked in-progress
# Now implement - all 5 files allowed
# Edit src/auth.py
# Edit src/middleware.py
# Edit src/models.py
# Write tests/test_auth.py
# Update docs/authentication.md
# Validation ALLOWS:
# ā
All changes attributed to feat-abc123
# ā
Session shows feature context
# ā
Work is trackable
Result: Multi-file feature work is tracked and attributed.
Scenario 3: Single-File Quick Fix (No Feature)
Situation: You notice a typo in a docstring.
# Edit a single file without creating a feature
# Edit src/utils.py (fix typo)
# Validation WARNS BUT ALLOWS:
# ā ļø PreToolUse Validation: Warning - activity may not be tracked
# File: src/utils.py (1 file)
# Reason: Single-file change without active feature
# Option: Create feature if this is significant work
# You can choose:
# - Continue (typo is trivial, doesn't need feature)
# - Cancel and create feature (if it's a bigger fix)
Result: Small fixes don't require features, but validation tracks the decision.
Working with HtmlGraph
RECOMMENDED: Use the Python SDK for AI agents (cleanest, fastest, most powerful)
Python SDK (PRIMARY INTERFACE - Use This!)
The SDK supports ALL collections with a unified interface. Use it for maximum performance and type safety.
from htmlgraph import SDK
# Initialize (auto-discovers .htmlgraph)
sdk = SDK(agent="claude")
# ===== ALL COLLECTIONS SUPPORTED =====
# Features (with builder support)
feature = sdk.features.create("User Authentication") \
.set_priority("high") \
.add_steps([
"Create login endpoint",
"Add JWT middleware",
"Write tests"
]) \
.save()
# Bugs
with sdk.bugs.edit("bug-001") as bug:
bug.status = "in-progress"
bug.priority = "critical"
# Chores, Spikes, Epics - all work the same way
chore = sdk.chores.where(status="todo")[0]
spike_results = sdk.spikes.all()
epic_steps = sdk.epics.get("epic-001").steps
# ===== EFFICIENT BATCH OPERATIONS =====
# Mark multiple items done (vectorized!)
sdk.bugs.mark_done(["bug-001", "bug-002", "bug-003"])
# Assign multiple items to agent
sdk.features.assign(["feat-001", "feat-002"], agent="claude")
# Custom batch updates (any attributes)
sdk.chores.batch_update(
["chore-001", "chore-002"],
{"status": "done", "agent_assigned": "claude"}
)
# ===== CROSS-COLLECTION QUERIES =====
# Find all in-progress work
in_progress = []
for coll_name in ['features', 'bugs', 'chores', 'spikes', 'epics']:
coll = getattr(sdk, coll_name)
in_progress.extend(coll.where(status='in-progress'))
# Find low-lift tasks
for item in in_progress:
if hasattr(item, 'steps'):
for step in item.steps:
if not step.completed and 'document' in step.description.lower():
print(f"š {item.id}: {step.description}")
SDK Performance (vs CLI):
- Single query: 3x faster
- 5 queries: 9x faster
- 10 batch updates: 16x faster
CLI (For One-Off Commands Only)
IMPORTANT: Always use uv run when running htmlgraph commands to ensure the correct environment.
ā ļø CLI is slower than SDK (400ms startup per command). Use for quick one-off queries only.
# Check Current Status
uv run htmlgraph status
uv run htmlgraph feature list
# Start Working on a Feature
uv run htmlgraph feature start <feature-id>
# Set Primary Feature (when multiple are active)
uv run htmlgraph feature primary <feature-id>
# Complete a Feature
uv run htmlgraph feature complete <feature-id>
When to use CLI vs SDK:
- CLI: Quick one-off shell command
- SDK: Everything else (faster, more powerful, better for scripts)
Strategic Planning & Dependency Analytics
NEW: HtmlGraph now provides intelligent analytics to help you make smart decisions about what to work on next.
Quick Start: Get Recommendations
from htmlgraph import SDK
sdk = SDK(agent="claude")
# Get smart recommendations on what to work on
recs = sdk.recommend_next_work(agent_count=1)
if recs:
best = recs[0]
print(f"š” Work on: {best['title']}")
print(f" Score: {best['score']:.1f}")
print(f" Why: {', '.join(best['reasons'])}")
Available Strategic Planning Features
1. Find Bottlenecks š§
Identify tasks blocking the most downstream work:
bottlenecks = sdk.find_bottlenecks(top_n=5)
for bn in bottlenecks:
print(f"{bn['title']} blocks {bn['blocks_count']} tasks")
print(f"Impact score: {bn['impact_score']}")
Returns: List of dicts with id, title, status, priority, blocks_count, impact_score, blocked_tasks
2. Get Parallel Work ā”
Find tasks that can be worked on simultaneously:
parallel = sdk.get_parallel_work(max_agents=5)
print(f"Can work on {parallel['max_parallelism']} tasks at once")
print(f"Ready now: {parallel['ready_now']}")
Returns: Dict with max_parallelism, ready_now, total_ready, level_count, next_level
3. Recommend Next Work š”
Get smart recommendations considering priority, dependencies, and impact:
recs = sdk.recommend_next_work(agent_count=3)
for rec in recs:
print(f"{rec['title']} (score: {rec['score']})")
print(f"Reasons: {rec['reasons']}")
print(f"Unlocks: {rec['unlocks_count']} tasks")
Returns: List of dicts with id, title, priority, score, reasons, estimated_hours, unlocks_count, unlocks
4. Assess Risks ā ļø
Check for dependency-related risks:
risks = sdk.assess_risks()
if risks['high_risk_count'] > 0:
print(f"Warning: {risks['high_risk_count']} high-risk tasks")
for task in risks['high_risk_tasks']:
print(f" {task['title']}: {task['risk_factors']}")
if risks['circular_dependencies']:
print("Circular dependencies detected!")
Returns: Dict with high_risk_count, high_risk_tasks, circular_dependencies, orphaned_count, recommendations
5. Analyze Impact š
See what completing a task will unlock:
impact = sdk.analyze_impact("feature-001")
print(f"Unlocks {impact['completion_impact']:.1f}% of remaining work")
print(f"Affects {impact['total_impact']} downstream tasks")
Returns: Dict with node_id, direct_dependents, total_impact, completion_impact, unlocks_count, affected_tasks
Recommended Decision Flow
At the start of each work session:
from htmlgraph import SDK
sdk = SDK(agent="claude")
# 1. Check for bottlenecks
bottlenecks = sdk.find_bottlenecks(top_n=3)
if bottlenecks:
print(f"ā ļø {len(bottlenecks)} bottlenecks found")
# 2. Get recommendations
recs = sdk.recommend_next_work(agent_count=1)
if recs:
best = recs[0]
print(f"\nš” RECOMMENDED: {best['title']}")
print(f" Score: {best['score']:.1f}")
print(f" Reasons: {', '.join(best['reasons'][:2])}")
# 3. Analyze impact
impact = sdk.analyze_impact(best['id'])
print(f" Impact: Unlocks {impact['unlocks_count']} tasks")
# 4. Check for parallel work (if coordinating)
parallel = sdk.get_parallel_work(max_agents=3)
if parallel['total_ready'] > 1:
print(f"\nā” {parallel['total_ready']} tasks available in parallel")
When to Use Each Feature
- find_bottlenecks(): At session start, during sprint planning
- recommend_next_work(): When deciding what task to pick up
- get_parallel_work(): When coordinating multiple agents
- assess_risks(): During project health checks, before milestones
- analyze_impact(): When choosing between high-effort tasks
Advanced: Direct Analytics Access
For advanced use cases, access the full analytics engine:
# Access Pydantic models with all fields
analytics = sdk.dep_analytics
bottlenecks = analytics.find_bottlenecks(top_n=5, min_impact=1.0)
parallel = analytics.find_parallelizable_work(status="todo")
recs = analytics.recommend_next_tasks(agent_count=3, lookahead=5)
risk = analytics.assess_dependency_risk(spof_threshold=2)
impact = analytics.impact_analysis("feature-001")
See also: docs/AGENT_STRATEGIC_PLANNING.md for complete guide
Orchestrator Workflow (Multi-Agent Delegation)
CRITICAL: When spawning subagents with Task tool, follow the orchestrator workflow.
When to Use Orchestration
Use orchestration (spawn subagents) when:
- Multiple independent tasks can run in parallel
- Work can be partitioned without conflicts
- Speedup factor > 1.5x
sdk.get_parallel_work()showsmax_parallelism >= 2
6-Phase Parallel Workflow
1. ANALYZE ā Check dependencies, assess parallelizability
2. PREPARE ā Cache shared context, partition files
3. DISPATCH ā Generate prompts via SDK, spawn agents in ONE message
4. MONITOR ā Track health metrics per agent
5. AGGREGATE ā Collect results, detect conflicts
6. VALIDATE ā Verify outputs, run tests
SDK Orchestration Methods (USE THESE!)
IMPORTANT: Use SDK methods instead of raw Task prompts!
from htmlgraph import SDK
sdk = SDK(agent="orchestrator")
# 1. ANALYZE - Check if work can be parallelized
parallel = sdk.get_parallel_work(max_agents=5)
if parallel["max_parallelism"] < 2:
print("Work sequentially instead")
# 2. PLAN - Get structured prompts with context
plan = sdk.plan_parallel_work(max_agents=3)
if plan["can_parallelize"]:
# 3. DISPATCH - Spawn all agents in ONE message
for p in plan["prompts"]:
Task(
subagent_type="general-purpose",
prompt=p["prompt"],
description=p["description"]
)
# 4-5. AGGREGATE - After agents complete
results = sdk.aggregate_parallel_results(agent_ids)
# 6. VALIDATE
if results["all_passed"]:
print("ā
Parallel execution validated!")
Why SDK Over Raw Prompts?
| Raw Task Prompt | SDK Orchestration |
|---|---|
| No context caching | Shares context efficiently |
| No file isolation | Prevents conflicts |
| Manual prompt writing | Structured prompts |
| No aggregation | Automatic result collection |
| No feature linking | Auto-links to work items |
Quick Reference
# Check parallelizability
parallel = sdk.get_parallel_work(max_agents=5)
# Plan parallel work
plan = sdk.plan_parallel_work(max_agents=3)
# Alternative: spawn individual agents
explorer_prompt = sdk.spawn_explorer(task="Find API endpoints", scope="src/api/")
coder_prompt = sdk.spawn_coder(feature_id="feat-123", context="...")
# Full orchestration
prompts = sdk.orchestrate("feat-123", exploration_scope="src/", test_command="pytest")
Anti-Patterns to Avoid
ā DON'T: Write raw prompts to Task tool
# BAD - bypasses SDK orchestration
Task(prompt="Fix the bug in auth.py...", subagent_type="general-purpose")
ā DO: Use SDK to generate prompts
# GOOD - uses SDK orchestration with proper context
prompt = sdk.spawn_coder(feature_id="bug-123", files_to_modify=["auth.py"])
Task(prompt=prompt["prompt"], ...)
ā DON'T: Send Task calls in separate messages (sequential)
# BAD - agents run one at a time
result1 = Task(...) # Wait
result2 = Task(...) # Then next
ā DO: Send all Task calls in ONE message (parallel)
# GOOD - true parallelism
for p in prompts:
Task(prompt=p["prompt"], ...) # All in same response
See also: packages/claude-plugin/skills/parallel-orchestrator/SKILL.md for detailed 6-phase workflow
Work Type Classification (Phase 1)
NEW: HtmlGraph now automatically categorizes all work by type to differentiate exploratory work from implementation.
Work Type Categories
All events are automatically tagged with a work type based on the active feature:
- feature-implementation - Building new functionality (feat-*)
- spike-investigation - Research and exploration (spike-*)
- bug-fix - Correcting defects (bug-*)
- maintenance - Refactoring and tech debt (chore-*)
- documentation - Writing docs (doc-*)
- planning - Design decisions (plan-*)
- review - Code review
- admin - Administrative tasks
Creating Spikes (Investigation Work)
Use Spike model for timeboxed investigation:
from htmlgraph import SDK, SpikeType
sdk = SDK(agent="claude")
# Create a spike with classification
spike = sdk.spikes.create("Investigate OAuth providers") \
.set_spike_type(SpikeType.TECHNICAL) \
.set_timebox_hours(4) \
.add_steps([
"Research OAuth 2.0 flow",
"Compare Google vs GitHub providers",
"Document security considerations"
]) \
.save()
# Update findings after investigation
with sdk.spikes.edit(spike.id) as s:
s.findings = "Google OAuth has better docs but GitHub has simpler integration"
s.decision = "Use GitHub OAuth for MVP, migrate to Google later if needed"
s.status = "done"
Spike Types:
TECHNICAL- Investigate technical implementation optionsARCHITECTURAL- Research system design decisionsRISK- Identify and assess project risksGENERAL- Uncategorized investigation
Creating Chores (Maintenance Work)
Use Chore model for maintenance tasks:
from htmlgraph import SDK, MaintenanceType
sdk = SDK(agent="claude")
# Create a chore with classification
chore = sdk.chores.create("Refactor authentication module") \
.set_maintenance_type(MaintenanceType.PREVENTIVE) \
.set_technical_debt_score(7) \
.add_steps([
"Extract auth logic to separate module",
"Add unit tests for auth flows",
"Update documentation"
]) \
.save()
Maintenance Types:
CORRECTIVE- Fix defects and errorsADAPTIVE- Adapt to environment changes (OS, dependencies)PERFECTIVE- Improve performance, usability, maintainabilityPREVENTIVE- Prevent future problems (refactoring, tech debt)
Session Work Type Analytics
Query work type distribution for any session:
from htmlgraph import SDK
sdk = SDK(agent="claude")
# Get current session
from htmlgraph.session_manager import SessionManager
sm = SessionManager()
session = sm.get_active_session(agent="claude")
# Calculate work breakdown
breakdown = session.calculate_work_breakdown()
# Returns: {"feature-implementation": 120, "spike-investigation": 45, "maintenance": 30}
# Get primary work type
primary = session.calculate_primary_work_type()
# Returns: "feature-implementation" (most common type)
# Query events by work type
spike_events = [e for e in session.get_events() if e.get("work_type") == "spike-investigation"]
Automatic Work Type Inference
Work type is automatically inferred from feature_id prefix:
# When you start a spike:
sdk.spikes.start("spike-123")
# ā All events auto-tagged with work_type="spike-investigation"
# When you start a feature:
sdk.features.start("feat-456")
# ā All events auto-tagged with work_type="feature-implementation"
# When you start a chore:
sdk.chores.start("chore-789")
# ā All events auto-tagged with work_type="maintenance"
No manual tagging required! The system automatically categorizes your work based on what you're working on.
Why This Matters
Work type classification enables you to:
- Differentiate exploration from implementation - "How much time was spent researching vs building?"
- Track technical debt - "What % of work is maintenance vs new features?"
- Measure innovation - "What's our spike-to-feature ratio?"
- Session context - "Was this primarily an exploratory session or implementation?"
Example Session Analysis:
# After a long session, analyze what you did:
session = sm.get_active_session(agent="claude")
breakdown = session.calculate_work_breakdown()
print(f"Primary work type: {session.calculate_primary_work_type()}")
print(f"Work breakdown: {breakdown}")
# Output:
# Primary work type: spike-investigation
# Work breakdown: {
# "spike-investigation": 65,
# "feature-implementation": 30,
# "documentation": 10
# }
# ā This was primarily an exploratory/research session
Feature Creation Decision Framework
CRITICAL: Use this framework to decide when to create a feature vs implementing directly.
Quick Decision Rule
Create a FEATURE if ANY apply:
- Estimated >30 minutes of work
- Involves 3+ files
- Requires new automated tests
- Affects multiple components
- Hard to revert (schema, API changes)
- Needs user/API documentation
Implement DIRECTLY if ALL apply:
- Single file, obvious change
- <30 minutes work
- No cross-system impact
- Easy to revert
- No tests needed
- Internal/trivial change
Decision Tree (Quick Reference)
User request received
āā Bug in existing feature? ā See Bug Fix Workflow in WORKFLOW.md
āā >30 minutes? ā CREATE FEATURE
āā 3+ files? ā CREATE FEATURE
āā New tests needed? ā CREATE FEATURE
āā Multi-component impact? ā CREATE FEATURE
āā Hard to revert? ā CREATE FEATURE
āā Otherwise ā IMPLEMENT DIRECTLY
Examples
ā CREATE FEATURE:
- "Add user authentication" (multi-file, tests, docs)
- "Implement session comparison view" (new UI, Playwright tests)
- "Fix attribution drift algorithm" (complex, backend tests)
ā IMPLEMENT DIRECTLY:
- "Fix typo in README" (single file, trivial)
- "Update CSS color" (single file, quick, reversible)
- "Add missing import" (obvious fix, no impact)
Default Rule
When in doubt, CREATE A FEATURE. Over-tracking is better than losing attribution.
See docs/WORKFLOW.md for the complete decision framework with detailed criteria, thresholds, and edge cases.
Session Workflow Checklist
MANDATORY: Follow this checklist for EVERY session. No exceptions.
Session Start (DO THESE FIRST)
- ā Activate this skill (done automatically)
- ā AUTO-SPIKE CREATED: Validation hook automatically creates an auto-spike for session exploration (see "Auto-Spike Integration" section)
- ā
RUN:
uv run htmlgraph session start-info- Get comprehensive session context (optimized, 1 call)- Replaces: status + feature list + session list + git log + analytics
- Reduces context usage from 30% to <5%
- ā Review active features and decide if you need to create a new one
- ā Greet user with brief status update
- ā DECIDE: Create feature or implement directly? (use decision framework in "Pre-Work Validation" section)
- ā
If creating feature: Use SDK or run
uv run htmlgraph feature start <id>
During Work (DO CONTINUOUSLY)
- ā
Feature MUST be marked "in-progress" before you write any code
- ā ļø VALIDATION NOTE: Validation will warn or deny multi-file changes without active feature (see "Pre-Work Validation" section)
- Single-file changes are allowed with warning
- 3+ file changes require active feature to proceed
- ā CRITICAL: Mark each step complete IMMEDIATELY after finishing it (use SDK)
- ā Document ALL decisions as you make them
- ā Test incrementally - don't wait until the end
- ā Watch for drift warnings and act on them immediately
How to Mark Steps Complete
IMPORTANT: After finishing each step, mark it complete using the SDK:
from htmlgraph import SDK
sdk = SDK(agent="claude")
# Mark step 0 (first step) as complete
with sdk.features.edit("feature-id") as f:
f.steps[0].completed = True
# Mark step 1 (second step) as complete
with sdk.features.edit("feature-id") as f:
f.steps[1].completed = True
# Or mark multiple steps at once
with sdk.features.edit("feature-id") as f:
f.steps[0].completed = True
f.steps[1].completed = True
f.steps[2].completed = True
Step numbering is 0-based (first step = 0, second step = 1, etc.)
When to mark complete:
- ā IMMEDIATELY after finishing a step
- ā Even if you continue working on the feature
- ā Before moving to the next step
- ā NOT at the end when all steps are done (too late!)
Example workflow:
- Start feature:
uv run htmlgraph feature start feature-123 - Work on step 0 (e.g., "Design models")
- MARK STEP 0 COMPLETE ā Use SDK:
with sdk.features.edit("feature-123") as f: f.steps[0].completed = True - Work on step 1 (e.g., "Create templates")
- MARK STEP 1 COMPLETE ā Use SDK:
with sdk.features.edit("feature-123") as f: f.steps[1].completed = True - Continue until all steps done
- Complete feature:
uv run htmlgraph feature complete feature-123
Session End (MUST DO BEFORE MARKING COMPLETE)
- ā
RUN TESTS:
uv run pytest- All tests MUST pass - ā VERIFY ATTRIBUTION: Check that activities are linked to correct feature
- ā CHECK STEPS: ALL feature steps MUST be marked complete
- ā CLEAN CODE: Remove all debug code, console.logs, TODOs
- ā
COMMIT WORK: Git commit your changes IMMEDIATELY (allows user rollback)
- Do this BEFORE marking the feature complete
- Include the feature ID in the commit message
- ā
COMPLETE FEATURE: Use SDK or run
uv run htmlgraph feature complete <id> - ā UPDATE EPIC: If part of epic, mark epic step complete
REMINDER: Completing a feature without doing all of the above means incomplete work. Don't skip steps.
Handling Drift Warnings
When you see a drift warning like:
Drift detected (0.74): Activity may not align with feature-self-tracking
Consider:
- Is this expected? Sometimes work naturally spans multiple features
- Should you switch features? Use
uv run htmlgraph feature primary <id>to change attribution - Is the feature scope wrong? The feature's file patterns or keywords may need updating
Session Continuity
At the start of each session:
- Review previous session summary (if provided)
- Note current feature progress
- Identify what remains to be done
- Ask the user what they'd like to work on
At the end of each session:
- The SessionEnd hook will generate a summary
- All activities are preserved in
.htmlgraph/sessions/ - Feature progress is updated automatically
Best Practices
Commit Messages
Include feature context:
feat(feature-id): Description of the change
- Details about what was done
- Why this approach was chosen
š¤ Generated with Claude Code
Task Descriptions
When using Bash tool, always provide a description:
# Good - descriptive
Bash(description="Install dependencies for auth feature")
# Bad - no context
Bash(command="npm install")
Decision Documentation
When making architectural decisions:
- Track with
uv run htmlgraph track "Decision" "Chose X over Y because Z" - Or note in the feature's HTML file under activity log
Dashboard Access
View progress visually:
uv run htmlgraph serve
# Open http://localhost:8080
The dashboard shows:
- Kanban board with feature status
- Session history with activity logs
- Graph visualization of dependencies
Key Files
.htmlgraph/features/- Feature HTML files (the graph nodes).htmlgraph/sessions/- Session HTML files with activity logsindex.html- Dashboard (open in browser)
Integration Points
HtmlGraph hooks track:
- SessionStart: Creates session, provides feature context
- PostToolUse: Logs every tool call with attribution
- UserPromptSubmit: Logs user queries
- SessionEnd: Finalizes session with summary
All data is stored as HTML files - human-readable, git-friendly, browser-viewable.