skills/agentic-patterns/SKILL.md
Fundamental patterns for effective agentic behavior. Teaches decomposition, tool orchestration, error recovery, context management, quality self-assessment, and knowing when to stop. Model-agnostic principles that make any agent more effective regardless of domain. Activate on: "how should I structure this agent", "agentic workflow", "agent patterns", "multi-step task", "tool orchestration", "/agentic-patterns", "decompose this", "agent best practices", "chain of actions", "when should the agent stop", "agent loop design". NOT for: creating agent infrastructure (use agent-creator), building DAGs (use windags-architect), specific tool implementation.
npx skillsauth add curiositech/windags-skills agentic-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are teaching effective agentic patterns. These are model-agnostic principles — they work for Claude, GPT, Gemini, or any LLM acting as an agent. The goal: agents that decompose well, use tools precisely, recover from errors, manage their context budget, assess their own quality, and know when to stop.
Use for:
NOT for:
Every effective agent embodies five capabilities:
1. DECOMPOSE — Break the problem into steps before acting
2. ORCHESTRATE — Choose and sequence tools with purpose
3. RECOVER — Handle failures without catastrophe
4. MANAGE — Spend context tokens like a budget
5. ASSESS — Know how well you did, and when to stop
Before acting, make three passes over the task:
Pass 1 — Scope: What does "done" look like? Define the exit condition first.
Pass 2 — Subtasks: What are the 3-7 concrete steps to reach "done"? Each step should be achievable with a single tool call or a small chain of tool calls.
Pass 3 — Dependencies: Which steps depend on which? Independent steps can parallelize. Dependent steps must serialize.
| Anti-Pattern | Why It Fails | Fix | |-------------|--------------|-----| | Acting before decomposing | Wasted tool calls, wrong direction | Always plan first, even briefly | | One giant subtask | No parallelism, no checkpoints | Split until each subtask is one tool call | | 20+ subtasks | Cognitive overhead, lost context | Merge related steps, aim for 3-7 | | No exit condition | Agent runs forever | Define "done" before starting | | Static plan | Can't adapt to discoveries | Replan after each wave of results |
Replan when:
Use the fewest tools with the narrowest scope to accomplish each subtask. Every tool call has costs:
Wrong: Read 20 files to understand a codebase. Right: Grep for the specific symbol, read the 2-3 files that contain it.
| Need | Preferred Tool | Why | |------|---------------|-----| | Find a file by name | Glob | Direct pattern match, no content scanning | | Find content in files | Grep | Targeted search, returns locations | | Understand a specific file | Read | Full context for one file | | Understand a codebase | Task (explore agent) | Delegates exploration, protects context | | Make a small change | Edit | Minimal diff, preserves surrounding code | | Create something new | Write | Fresh file, no edit conflicts | | Run a command | Bash | System interaction, build/test | | Complex sub-problem | Task (subagent) | Isolates context, parallelizable |
Sequential (use when outputs feed into inputs):
Read file → understand structure → Edit specific section → Run tests
Parallel (use when tasks are independent):
[Grep for pattern A] + [Grep for pattern B] + [Read config file]
→ all complete → synthesize findings
Rule: If two tool calls don't share data, run them in parallel. If one needs the other's output, serialize them.
Spawn a subagent (Task tool) when:
Do NOT spawn a subagent when:
When a tool call fails, escalate through four levels:
Level 1 — Retry with adjustment: Fix the obvious issue (typo, wrong path, missing arg) and retry once.
Level 2 — Alternative approach: Use a different tool or strategy to achieve the same goal. If Edit fails, try a different Edit. If Grep finds nothing, try Glob with a different pattern.
Level 3 — Reduce scope: If the full task can't be completed, identify the largest subset that can. Deliver partial results with a clear note about what's missing.
Level 4 — Escalate to user: If you've tried levels 1-3 and the task is still blocked, describe what you tried, what failed, and ask the user for guidance. Never loop silently.
| Anti-Pattern | Consequence | Fix | |-------------|-------------|-----| | Retry the same thing 5 times | Wasted tokens, same failure | One retry with adjustment, then Level 2 | | Ignore the error and continue | Cascading failures downstream | Every error must be handled | | Simplify the task to make it work | User gets less than they asked for | Only reduce scope at Level 3, and disclose it | | Give up immediately | User loses trust | Exhaust Level 1-2 before escalating |
When a tool call fails:
Every token in your context window costs money and attention. Treat context like a budget:
Reserve 30% of your effective context for final synthesis and output. If you've used 70% of your context on research, stop researching and start synthesizing.
| Pattern | How | Saves | |---------|-----|-------| | Targeted reads | Read specific line ranges, not whole files | 50-90% per file | | Grep before read | Find the exact location, then read only that section | Avoids reading irrelevant files | | Subagent delegation | Expensive exploration happens in isolated context | Protects main context | | Summarize early | After a research phase, write a summary before continuing | Prevents re-reading | | Batch tool calls | Run independent calls in parallel | Reduces round trips |
After completing a task, assess your confidence on two axes:
Completeness: Did you address everything the user asked for?
Correctness: How likely is your output to be right?
Stop when ANY of these are true:
Continue when ALL of these are true:
Resist the urge to add improvements the user didn't ask for. Every "one more thing" costs tokens, risks introducing bugs, and delays delivery. If you see an improvement opportunity, note it in your response — don't implement it unasked.
Phase 1 (Scout): Read, Grep, Glob — understand the territory
Phase 2 (Plan): Decompose based on what you found
Phase 3 (Act): Edit, Write, Bash — execute the plan
Phase 4 (Verify): Run tests, check results
Best for: Bug fixes, feature additions, refactoring. You need to understand before you change.
Wave 0: [Research A] + [Research B] + [Research C] ← parallel subagents
Wave 1: [Synthesize findings] ← single agent
Wave 2: [Implement based on synthesis] ← single agent
Best for: Tasks requiring multiple independent information sources. Research tasks, competitive analysis, multi-file understanding.
Loop:
1. Produce draft output
2. Evaluate against criteria
3. If criteria met → done
4. Identify largest gap
5. Fix the gap → go to 1
Max iterations: 3-5
Best for: Creative tasks, code generation, content production. Each pass improves quality.
Stage 1: Raw extraction (fast, broad)
Stage 2: Filtering (remove noise)
Stage 3: Enrichment (add detail to survivors)
Stage 4: Final synthesis
Best for: Data processing, research synthesis, skill compression. Each stage narrows the working set.
Before considering an agentic task complete:
[ ] Exit condition defined before starting
[ ] Task decomposed into 3-7 concrete subtasks
[ ] Dependencies identified (what must serialize vs parallelize)
[ ] Each tool call has a clear purpose (no exploratory fishing)
[ ] Errors handled at the appropriate recovery level
[ ] Context budget tracked (not over 70% before synthesis)
[ ] Output addresses every part of the user's request
[ ] Confidence self-assessed on completeness and correctness
[ ] Improvements not requested by user noted but not implemented
[ ] Clear stopping point reached (exit condition met)
All five pillars follow one meta-pattern: think before acting, act with precision, assess after acting.
THINK: What am I trying to do? How will I know it's done?
ACT: Use the minimum tools with maximum precision.
ASSESS: Did it work? What's my confidence? Should I continue?
Agents that skip THINK waste tokens exploring. Agents that skip ASSESS don't know when to stop. Agents that skip ACT just plan forever. All three, in that order, every cycle.
tools
Building resilient distributed systems with circuit breakers, retries with full-jitter exponential backoff, retry budgets (per-request 3-attempt + per-client 10% ratio per Google SRE), deadline propagation, and the cascading-failure math (4 layers × 3 retries = 64x amplification). Grounded in Resilience4j, Microsoft Cloud Patterns, AWS Architecture Blog (Marc Brooker), and Google SRE Book.
testing
Designing HTTP cache headers that work correctly across browsers, CDNs, and shared proxies — `Cache-Control` directives per RFC 9111, `stale-while-revalidate` and `stale-if-error` per RFC 5861, the Vary header for varying responses, and surrogate keys for tag-based purging. Grounded in IETF RFCs and Cloudflare/Fastly docs.
development
Use when designing or fixing a Content Security Policy on a real site, choosing between nonce-based and hash-based CSP, adding strict-dynamic, debugging "Refused to execute inline script" errors, deploying CSP in report-only mode first, configuring report-to / report-uri, or auditing an existing policy for unsafe-inline / unsafe-eval / wildcards. Triggers: "CSP blocks legitimate inline script", strict-dynamic, nonce-{RANDOM}, sha256-{HASH}, object-src none, base-uri none, frame-ancestors, Trusted Types, X-Content-Security-Policy obsolete, report-only vs enforced. NOT for general HTTP security headers (HSTS, COOP/COEP), Trusted Types deep dive, CORS configuration, or building a WAF.
tools
Choosing and operating an HTTP API versioning strategy that doesn't break clients — Stripe's date-based pinned versions, the Deprecation/Sunset header pair (RFC 9745 + RFC 8594), URI vs header vs media-type approaches, and the version-transformer pattern. Grounded in Stripe's published architecture and IETF RFCs.