kienbui1995/magic-powers/agentic-ai-patterns
Claude Code and agent skill by kienbui1995/magic-powers
- community
Checking that the SKILL.md file is still in the repository.
Use when designing AI agents - tool use, multi-agent orchestration, state management, planning loops, error recovery, and agent evaluation
Install
npx vskill@latest install kienbui1995/magic-powers/agentic-ai-patternsSKILL.md
The same SKILL.md was published earlier as kienbui1995/magic-powers/agentic-ai-patterns.
Agentic AI Patterns
Overview
An agent is an LLM in a loop: observe → think → act → observe. The hard part isn't the LLM — it's the loop control, error recovery, and knowing when to stop.
When to Use
- Building AI agents that take actions (not just chat)
- Designing tool-use patterns
- Orchestrating multiple agents
- Debugging agent loops that get stuck or go off-track
Agent Architecture
Core Components
| Component | Purpose | |
|---|---|---|
| Planner | Break goal into steps | |
| Executor | Run tools, API calls | |
| Observer | Parse tool results | |
| Decider | Continue, retry, or stop | |
| Memory | Track state across steps |
Patterns
1. ReAct (Reasoning + Acting)
2. Plan-and-Execute
3. Multi-Agent (specialist delegation)
Graph-Based Agents (LangGraph)
Beyond simple loops, production agents use directed graphs for complex branching logic:
Key patterns:
- Parallel tool execution — fan-out to multiple tools simultaneously, merge results
- Conditional branching — route based on output content, confidence, or tool results
- Subgraph composition — nest agent graphs for modularity
- Persistence — LangGraph's checkpointing enables pause/resume across sessions
Tool Design Rules
- Clear names —
search_documentsnottool_1 - Typed parameters — JSON schema for every tool
- Bounded output — truncate large results, paginate
- Error messages — return actionable errors, not stack traces
- Idempotent — safe to retry on failure
Error Recovery
| Failure | Recovery | |
|---|---|---|
| Tool returns error | Retry once, then report to user | |
| Agent loops >10 steps | Force stop, summarize progress | |
| Off-topic drift | Check goal alignment every 3 steps | |
| Hallucinated tool call | Validate tool name exists before calling | |
| Timeout | Set max execution time, graceful exit |
State Management
- Persist state for long-running agents
- Log every step for debugging
- Set hard limits: max steps, max time, max cost
Memory Architecture
Agents need different memory types for different purposes:
| Type | Storage | Lifetime | Use case | |
|---|---|---|---|---|
| In-context | Token window | Current session | Active task state, recent tool results | |
| Session | DB (Redis/Postgres) | One conversation | User preferences, conversation history | |
| Long-term | Vector DB | Persistent | User facts, past decisions, learned patterns | |
| Episodic | DB + embeddings | Persistent | Past task completions, examples |
Context window management:
When to use external memory:
- Conversation > 20 turns → summarize and store
- User mentions facts that apply beyond this session → upsert to long-term store
- Agent needs to "remember" past tasks → episodic store with semantic search
Human-in-the-Loop
Design confidence-based escalation rather than binary human/autonomous:
When to require human approval:
- Irreversible actions (delete, send, purchase, deploy)
- Low confidence + high stakes
- Novel situation not seen in training
- User explicitly requested oversight
- Regulatory requirement (financial, medical)
Graceful timeout: If no response within timeout → escalate or abort safely, never proceed on assumption.
Anti-Patterns
| Pattern | Fix | |
|---|---|---|
| No max iterations | Always set a loop limit | |
| Agent calls itself recursively | Detect cycles, break loop | |
| Too many tools (>15) | Group into categories, use router | |
| No logging | Log every thought/action/observation | |
| Trusting agent output blindly | Validate before executing side effects |
Cost-Aware Agent Design
Agent costs compound: each step adds tokens. Design for efficiency:
Token budgets:
Tool selection strategy:
- Cheap tools first (search before synthesize)
- Cache tool results for duplicate calls in same session
- Use smaller model for tool selection, larger for final synthesis
- Parallel tools when independent (fan-out saves latency and doesn't add cost)
Per-task cost tracking:
Integration
- magic-powers:prompt-engineering — design agent system prompts
- magic-powers:llm-evaluation — evaluate agent task completion
- magic-powers:ai-safety-guardrails — guard agent actions
- magic-powers:llm-observability — monitor agent runs
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/agentic-ai-patterns/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/kienbui1995/magic-powers/agentic-ai-patterns)