skills/dowwie/control-loop-extraction/SKILL.md
Extract and analyze agent reasoning loops, step functions, and termination conditions. Use when needing to (1) understand how an agent framework implements reasoning (ReAct, Plan-and-Solve, Reflection, etc.), (2) locate the core decision-making logic, (3) analyze loop mechanics and termination conditions, (4) document the step-by-step execution flow of an agent, or (5) compare reasoning patterns across frameworks.
npx skillsauth add aiskillstore/marketplace control-loop-extractionInstall 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.
Extracts and documents the core agent reasoning loop from framework source code.
ReAct (Reason + Act)
# Signature: Thought → Action → Observation cycle
while not done:
thought = llm.generate(prompt) # Reasoning
action = parse_action(thought) # Action selection
observation = execute(action) # Environment feedback
prompt = update_prompt(observation) # Loop continuation
Plan-and-Solve
# Signature: Upfront planning, then execution
plan = llm.generate("Create a plan for...")
for step in plan.steps:
result = execute_step(step)
if needs_replan(result):
plan = replan(...)
Reflection
# Signature: Act → Self-critique → Adjust
while not done:
action = llm.generate(prompt)
result = execute(action)
critique = llm.generate(f"Evaluate: {result}")
if critique.needs_adjustment:
prompt = adjust_approach(critique)
Tree-of-Thoughts
# Signature: Branch → Evaluate → Select
thoughts = [generate_thought() for _ in range(n)]
scores = [evaluate(t) for t in thoughts]
best = select_best(thoughts, scores)
The "step function" is the atomic unit of agent execution. Extract:
# Common step function structure
def step(self, state):
# 1. Assemble input
messages = self._build_messages(state)
# 2. Call LLM
response = self.llm.invoke(messages)
# 3. Parse output
parsed = self._parse_response(response)
# 4. Dispatch
if parsed.is_tool_call:
return self._execute_tool(parsed.tool, parsed.args)
else:
return AgentFinish(parsed.final_answer)
| Condition | Implementation | Risk |
|-----------|----------------|------|
| Step limit | if step_count >= max_steps | May cut off valid execution |
| Token limit | if total_tokens >= max_tokens | May truncate mid-thought |
| Explicit finish | if action.type == "finish" | Relies on LLM cooperation |
| Timeout | if elapsed > timeout | Wall-clock unpredictable |
| Loop detection | if state in seen_states | Requires state hashing |
| Error threshold | if error_count >= max_errors | May exit on recoverable errors |
# DANGEROUS: No exit condition
while True:
result = agent.step()
if result.is_done: # What if LLM never outputs done?
break
Fix: Always include a step counter:
for step in range(max_steps):
result = agent.step()
if result.is_done:
break
else:
logger.warning("Hit max steps limit")
## Control Loop Analysis: [Framework Name]
### Reasoning Topology
- **Pattern**: [ReAct | Plan-and-Solve | Reflection | Tree-of-Thoughts | Hybrid]
- **Location**: `path/to/agent.py:L45-L120`
### Step Function
- **Input Assembly**: [Description of context building]
- **LLM Call**: [Method and parameters]
- **Parser**: [How output is structured]
- **Dispatch Logic**: [Tool vs Finish decision]
### Termination Conditions
1. [Condition 1 with code reference]
2. [Condition 2 with code reference]
3. ...
### Loop Detection
- **Method**: [Heuristic | State hash | None]
- **Implementation**: [Code reference or N/A]
codebase-mapping to identify agent filescomparative-matrix for pattern comparisonarchitecture-synthesis for new loop designdevelopment
Apple Human Interface Guidelines for content display components. Use this skill when the user asks about charts component, collection view, image view, web view, color well, image well, activity view, lockup, data visualization, content display, displaying images, rendering web content, color pickers, or presenting collections of items in Apple apps. Also use when the user says how should I display charts, what's the best way to show images, should I use a web view, how do I build a grid of items, what component shows media, or how do I present a share sheet. Cross-references: hig-foundations for color/typography/accessibility, hig-patterns for data visualization patterns, hig-components-layout for structural containers, hig-platforms for platform-specific component behavior.
tools
Automate HelpDesk tasks via Rube MCP (Composio): list tickets, manage views, use canned responses, and configure custom fields. Always search tools first for current schemas.
testing
Expert Haskell engineer specializing in advanced type systems, pure functional design, and high-reliability software. Use PROACTIVELY for type-level programming, concurrency, and architecture guidance.
tools
GraphQL gives clients exactly the data they need - no more, no less. One endpoint, typed schema, introspection. But the flexibility that makes it powerful also makes it dangerous. Without proper controls, clients can craft queries that bring down your server. This skill covers schema design, resolvers, DataLoader for N+1 prevention, federation for microservices, and client integration with Apollo/urql. Key insight: GraphQL is a contract. The schema is the API documentation. Design it carefully.