agentic-flow-builder
Guide for building dynamic agentic flows using ReAcTree hierarchical decomposition and Anthropic's workflow patterns. This skill should be used when users want to create complex multi-step agent workflows with deterministic gates, business rules, and comprehensive audit trails.
What this skill does
# Agentic Flow Builder
This skill provides comprehensive guidance for building production-grade agentic flows that combine:
- **ReAcTree** hierarchical agent tree decomposition for long-horizon task planning
- **Anthropic's workflow patterns** for effective agent design
- **Business Rules Engine (BRE)** for deterministic decision-making at gates
- **Dual memory system** (episodic + working) for context management
- **SQLite persistence** with full audit trails
## Core Philosophy
**Start simple, add complexity only when justified.** Many problems can be solved with a single optimized LLM call. Only use agentic flows when the task requires:
- Multi-step decomposition
- Dynamic routing based on conditions
- Iterative refinement
- Complex orchestration across multiple specialized agents
## When to Use Agentic Flows
Create an agentic flow when you need:
1. **Long-horizon task planning** - Complex goals requiring hierarchical decomposition
2. **Deterministic gating** - Business rule-based decisions (not AI guesswork)
3. **Workflow orchestration** - Coordinating multiple specialized agents
4. **Audit requirements** - Complete traceability of decisions and outcomes
5. **Memory across executions** - Learning from past successful/failed attempts
## Architecture Components
### 0. Dynamic Agent Assignment
The system automatically selects the best agent for each task based on:
- **Task description** - Semantic matching with agent capabilities
- **Required tags** - Specific skills needed (e.g., "code", "security", "data")
- **Agent type preference** - General Claude models, Task agents, or External services
- **Performance history** - Learns from past successes/failures
**Agents are discovered dynamically:**
- Claude models (Sonnet, Opus, Haiku)
- Claude Code Task agents (auto-discovered)
- Custom plugin agents
- External API services
**Hot-reload support:** New agents are automatically available without restarting.
**Configuration example:**
```python
agent_node_config = {
"goal": "Review code for security vulnerabilities",
"required_tags": ["code", "security", "review"],
"prefer_agent_type": "task", # Prefer task agents if available
"store_episodic": True # Learn from this execution
}
```
The orchestrator will:
1. Find all agents with "code", "security", "review" capabilities
2. Prefer task agents (like "code-reviewer" if available)
3. Fall back to general Claude models if no specialized agent exists
4. Track performance and improve selection over time
### 1. Hierarchical Agent Tree (ReAcTree)
The flow is represented as a tree where:
- **Root nodes** - Entry points to the flow
- **Agent nodes** - LLM-capable reasoning units handling specific subgoals
- **Control flow nodes** - Orchestration using workflow patterns
- **Gate nodes** - Deterministic decision points using BRE
Each node can dynamically expand into child nodes, enabling hierarchical decomposition.
### 2. Business Rules Engine (BRE)
Provides **deterministic** decision-making at gates to avoid AI inconsistency.
**Rule condition language:**
```python
# Simple comparison
{
"field": "user.age",
"operator": ">=",
"value": 18
}
# Logical AND/OR
{
"AND": [
{"field": "status", "operator": "==", "value": "active"},
{"field": "balance", "operator": ">", "value": 0}
]
}
# Pattern matching
{
"MATCHES": {
"field": "email",
"pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"
}
}
```
**Why BRE over AI decisions:**
- **Consistency** - Same input always produces same output
- **Explainability** - Clear audit trail of why decisions were made
- **Reliability** - No hallucination or temperature-based variance
- **Compliance** - Meets regulatory requirements for deterministic behavior
### 3. Workflow Patterns (Anthropic)
Five proven patterns for effective agent design:
#### Pattern 1: Prompt Chaining
Sequential LLM calls where each processes prior output.
**When to use:** Decomposable tasks where intermediate steps improve accuracy.
**Example:** Content generation → Translation → Fact-checking
**Implementation:**
```python
control_flow_node = {
"node_type": "control_flow",
"pattern": "prompt_chaining",
"children": [
{"name": "generate_content", "type": "agent"},
{"name": "translate", "type": "agent"},
{"name": "fact_check", "type": "agent"}
]
}
```
#### Pattern 2: Routing
Classify inputs and route to specialized handlers.
**When to use:** Multi-category problems where specialization improves performance.
**Example:** Support ticket routing (technical/billing/account)
**Implementation:** Use BRE routing rules to deterministically select the appropriate handler.
#### Pattern 3: Parallelization
Simultaneous execution via sectioning or voting.
**When to use:** Independent subtasks or when multiple perspectives improve confidence.
**Example:** Multi-file code analysis, consensus-based decision making
#### Pattern 4: Orchestrator-Workers
Central LLM dynamically breaks tasks and delegates to workers.
**When to use:** Unpredictable subtask requirements.
**Example:** Multi-file codebase modifications
#### Pattern 5: Evaluator-Optimizer
Iterative generation and evaluation loops.
**When to use:** Clear quality criteria exist and refinement improves output.
**Example:** Code generation with test-driven refinement
### 4. Dual Memory System
**Episodic Memory** - Goal-specific examples for context retrieval
- Stores successful (and failed) past executions
- Retrieved based on goal similarity
- Provides in-context learning examples
**Working Memory** - Shared observations during execution
- Stores intermediate results
- Shared across nodes in same execution
- Enables context passing without parameter threading
## Flow Creation Process
### Step 1: Define the Goal and Scope
Ask clarifying questions:
1. What is the overall goal?
2. Can this be solved with a single LLM call?
3. What are the distinct steps or decisions required?
4. Are there deterministic decision points (gates)?
5. Do you need audit trails for compliance?
**Example dialogue:**
- "What problem are you trying to solve?"
- "Walk me through the ideal workflow step by step"
- "Are there any yes/no decisions based on specific criteria?"
- "Do you need to track why certain paths were taken?"
### Step 2: Choose Execution Mode
**Workflow Mode** - Predefined paths with deterministic logic
- Predictable, testable, explainable
- Use when steps are known in advance
- Lower cost, faster execution
**Agent Mode** - LLM-directed autonomous execution
- Flexible, adapts to unexpected situations
- Use for open-ended exploration
- Higher cost, requires extensive testing
**Hybrid Mode** - Mix of both
- Workflows for known paths, agents for complex reasoning
- **Recommended** for most production use cases
### Step 3: Design the Tree Structure
Map out the hierarchical decomposition:
```
Root
├── Gate: Check Prerequisites
│ └── Agent: Validate Input Data
├── Control Flow: Main Process (Orchestrator-Workers)
│ ├── Agent: Orchestrator (Plan subtasks)
│ ├── Agent: Worker 1 (Execute subtask 1)
│ ├── Agent: Worker 2 (Execute subtask 2)
│ └── Agent: Synthesizer (Combine results)
└── Control Flow: Post-Process (Evaluator-Optimizer)
├── Agent: Generator (Create output)
└── Agent: Evaluator (Validate quality)
```
### Step 4: Define Business Rules
For each gate node, define the business rules:
**Rule attributes:**
- **name** - Descriptive name
- **rule_type** - gate, validation, transformation, routing
- **condition** - Expression using BRE language
- **action** - What to do when rule fires (for routing/transformation)
- **priority** - Execution order (higher first)
**Example:**
```python
{
"name": "Credit Approval Gate",
"rule_type": "gate",
"condition": {
"AND": [
{"field": "credit_score", "operator": ">=", "value": 650},
{"field": "debt_to_income", "operator"Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.