xiaohongshu
xiaohongshu
agentdb-state-manager
Persistent state management using AgentDB (DuckDB) for workflow analytics and checkpoints. Provides read-only analytics cache synchronized from TODO_*.md files, enabling: - Complex dependency graph queries - Historical workflow metrics - Context checkpoint storage/recovery - State transition ana...
Full skill instructions
The AgentDB State Manager provides persistent database storage for workflow state tracking using DuckDB through Claude Code's AgentDB integration. This skill enables:
Primary source of truth: TODO_*.md files (AgentDB is an analytics cache)
Primary purpose: Data gathering and analysis
Workflow phase: Cross-phase (Utilities) - All phases (1-6)
Use this skill when:
Triggered by keywords: "analyze workflow", "query state", "checkpoint", "workflow metrics", "task dependencies"
Phase integration: Cross-phase (Utilities)
This skill integrates with all workflow phases:
Phase 0 (Setup):
Phase 1 (Planning - BMAD):
Phase 2 (Specification + Implementation):
Phase 3 (Quality):
Phase 4 (Integration):
Phase 5 (Release):
Phase 6 (Hotfix):
Context checkpoints (all phases):
Orchestrator integration:
This skill follows the local workflow system patterns which extend official Claude Code skill specifications:
Official Claude Code Skills:
Local Pattern Extensions:
file_structure:
frontmatter:
directory_organization:
These extensions support the multi-phase workflow system while maintaining compatibility with core Claude Code concepts.
TODO_*.md (source of truth)
↓
sync_todo_to_db.py
↓
AgentDB (DuckDB)
↓
query_state.py / analyze_metrics.py
↓
Analytics results
AgentDB requires a session ID for database identification. This skill uses:
Method: Timestamp-based (reproducible)
from datetime import datetime
import hashlib
# Generate session ID from current timestamp
current_time = datetime.utcnow().isoformat()
session_id = hashlib.md5(current_time.encode()).hexdigest()[:16]
# Example: "f8e7d6c5b4a39281"
Rationale: Provides reproducible session IDs across agent invocations within the same timeframe, balancing uniqueness with reproducibility.
Core principle: NEVER UPDATE or DELETE records - always INSERT new records
Primary table: workflow_records
CREATE TABLE IF NOT EXISTS workflow_records (
record_id UUID PRIMARY KEY DEFAULT uuid(),
record_datetimestamp TIMESTAMP DEFAULT current_timestamp,
object_id VARCHAR NOT NULL, -- Stable ID for workflow object
object_type VARCHAR NOT NULL, -- 'feature', 'task', 'epic', etc.
object_state VARCHAR NOT NULL, -- '20_in-progress', '99_done', etc.
object_metadata JSON -- Framework, dependencies, etc.
);
CREATE INDEX idx_records_object
ON workflow_records(object_id, record_datetimestamp DESC);
Current state query pattern:
-- Get latest state for each object
SELECT DISTINCT ON (object_id)
object_id, object_type, object_state, object_metadata
FROM workflow_records
WHERE object_type = 'task'
ORDER BY object_id, record_datetimestamp DESC;
# Initialize database schema and load state definitions
python .claude/skills/agentdb-state-manager/scripts/init_database.py
What it does:
# Sync all TODO_*.md files to database
python .claude/skills/agentdb-state-manager/scripts/sync_todo_to_db.py
# Sync specific TODO file
python .claude/skills/agentdb-state-manager/scripts/sync_todo_to_db.py \
TODO_feature_20251023T143000Z_my-feature.md
What it does:
# Get current state of all workflows
python .claude/skills/agentdb-state-manager/scripts/query_state.py
# Query specific workflow
python .claude/skills/agentdb-state-manager/scripts/query_state.py \
--slug my-feature
# Query task dependencies
python .claude/skills/agentdb-state-manager/scripts/query_state.py \
--dependencies --task impl_003
What it does:
# Generate metrics report
python .claude/skills/agentdb-state-manager/scripts/analyze_metrics.py
# Historical trends
python .claude/skills/agentdb-state-manager/scripts/analyze_metrics.py \
--trends --days 30
# Bottleneck analysis
python .claude/skills/agentdb-state-manager/scripts/analyze_metrics.py \
--bottlenecks
What it does:
# Store checkpoint at 100K tokens
python .claude/skills/agentdb-state-manager/scripts/checkpoint_manager.py \
store --todo TODO_feature_*.md
# List available checkpoints
python .claude/skills/agentdb-state-manager/scripts/checkpoint_manager.py list
# Restore from checkpoint
python .claude/skills/agentdb-state-manager/scripts/checkpoint_manager.py \
restore --checkpoint-id <uuid>
What it does:
✓ DO: Treat TODO_*.md files as source of truth ✗ DON'T: Modify TODO files based on AgentDB state
Rationale: Files are git-tracked and permanent; AgentDB sessions last 24 hours
✓ DO: Run sync_todo_to_db.py after every TODO file update ✗ DON'T: Let AgentDB state drift from file state
Rationale: AgentDB is a cache - it must stay synchronized
✓ DO: Use AgentDB for dependency graphs, metrics, historical analysis ✗ DON'T: Use for simple current state queries (parse TODO file instead)
Rationale: Minimize token overhead - use database for queries that justify the cost
✓ DO: Always INSERT new records for state changes ✗ DON'T: UPDATE or DELETE existing records
Rationale: Preserves full history for temporal analysis
✓ DO: Re-initialize at session start if needed ✗ DON'T: Assume AgentDB persists across days
Rationale: 24-hour auto-deletion - treat as ephemeral cache
Purpose: Initialize AgentDB schema and load state definitions When to run: First use in a session, or if schema corrupted Token cost: ~300-400 tokens
Purpose: Sync TODO_*.md files to AgentDB When to run: After every TODO file update Token cost: ~200-300 tokens per TODO file
Purpose: Query current workflow state and dependencies When to run: Complex state queries (dependency graphs, critical paths) Token cost: ~100-200 tokens per query
Purpose: Historical metrics and trend analysis When to run: End of phase, workflow retrospectives Token cost: ~400-600 tokens (complex queries)
Purpose: Store/restore context checkpoints When to run: At 100K token threshold, or before context reset Token cost: ~200-400 tokens (store + verify)
Complex dependency query:
Same query:
Savings: ~3,500 tokens (92% reduction) for complex queries
Before AgentDB:
After AgentDB:
Savings: ~3,050 tokens (92% reduction)
This skill implements the MIT Agent Synchronization Pattern based on:
Meng, E., & Jackson, D. (2025). "What You See Is What It Does: A Structural Pattern for Legible Software." Onward! at SPLASH 2025. arXiv:2508.14511v1. https://arxiv.org/abs/2508.14511
Key concepts from the paper:
agent_synchronizations table)The pattern improves incrementality, integrity, and transparency in multi-agent workflows.
v1.0.0 (2025-11-02):
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience