agentleFS
NikoxkxNikoxkx/Agent-Skills/skills/ai-ml/agent-chain-designer/SKILL.md

agent-chain-designer

Skill1 starsChanged 5 months agoApache-2.0View on GitHub

Designs multi-step AI agent chains with tool use, planning, and error recovery. Use when building agentic systems that require planning, tool calls, or multi-turn reasoning.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use LangSmith, Phoenix, Helicone, or custom tracing.

    line 62

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Overview

Designs and implements reliable multi-step AI agent chains. Covers chain types (sequential, parallel, branching, looping), tool definition (JSON schema + execution), planning patterns (ReAct, Plan-and-Execute, Reflexion), error recovery (retry, fallback, human-in-the-loop), state management, observability (tracing), and complete implementation templates using LangChain, LlamaIndex, or custom code.

When to Use This Skill

  • Building agents that need to use tools, plan, or perform multi-step reasoning.
  • The user describes a complex task that requires "research then act", "use these tools in sequence", or "handle errors gracefully".
  • Existing single-prompt or simple RAG approaches are insufficient.

Prerequisites

  • Clear task that benefits from tool use or multi-step reasoning.
  • Tools/APIs the agent will call (with authentication).
  • LLM that supports tool calling / function calling well (Claude 3, GPT-4, Gemini 1.5, etc.).
  • (Recommended) LangChain, LlamaIndex, or a custom agent framework.

Steps

  1. Decompose the task:
    • What are the atomic steps?
    • Which steps require tools vs pure reasoning?
    • What are the failure modes and how should the agent recover?
  2. Define tools (critical):
    • Name, description (the model reads this), parameters (JSON Schema).
    • Implementation (the actual function the agent calls).
    • Return value format (the model sees this).
    • Error handling inside the tool (never let the tool crash the agent).
  3. Choose agent architecture:
    • ReAct (Thought → Action → Observation loop) — very popular and effective.
    • Plan-and-Execute (high-level plan first, then execute steps).
    • Reflexion / self-critique (agent critiques its own output and retries).
    • Hierarchical (manager agent + specialist agents).
  4. State & memory:
    • Short-term (conversation history, scratchpad).
    • Long-term (vector store of past experiences or facts).
    • How to summarize or prune history when context grows.
  5. Error recovery & control flow:
    • Retry with different prompt or tool.
    • Fallback to simpler method or human.
    • Max iterations / timeout to prevent infinite loops.
    • Structured output for control (e.g., "next_action": "tool" | "final_answer" | "ask_human").
  6. Observability:
    • Log every thought, action, observation, and final answer.
    • Use LangSmith, Phoenix, Helicone, or custom tracing.
    • Capture token usage and latency per step.
  7. Output:
    • Tool definitions (JSON Schema + Python functions).
    • Agent prompt(s) (system + ReAct format).
    • Full agent loop code (or LangChain/LlamaIndex agent).
    • Error handling and recovery logic.
    • Example run trace (good and bad paths).
    • Evaluation approach for the agent.

Examples

A complete ReAct-style agent for "research a company and draft a personalized outreach email" with tools for web search, company info lookup, email draft, and human approval step, including full prompts, tool schemas, the agent loop, and tracing is included.

Edge Cases & Error Handling

  • Tool returns garbage: Agent should detect low-quality observation and either retry the tool with better params or fall back.
  • Infinite loops: Hard max_steps + timeout.
  • Cost explosion: Track cumulative tokens/cost; stop early if budget exceeded.
  • Hallucinated tool calls: The framework should only allow calling tools you defined.

Verification

  1. The agent successfully completes the happy-path task using tools.
  2. On a failing tool or bad intermediate result, it recovers (retries, falls back, or asks for help).
  3. Traces are complete and readable (you can debug why it did what it did).
  4. It does not loop forever or spend excessive tokens.
  5. On a held-out set of tasks, success rate is measured and acceptable.
  6. Success: The agent reliably accomplishes the multi-step goal with appropriate tool use and graceful handling of problems.

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.