Extended: Claude Agent Workflow Deep Dive
This section uses a combination of graphics and text to show how Claude transforms a vague user instruction into precise code execution through a "progressive disclosure" architecture.
Core Flow Diagram (The Loop)
User inputs instruction -> Claude scans metadata of all installed Skills (Name & Description only)
Claude discovers Skill description match during reasoning -> decides to [activate] the Skill
System reads the Skill's SKILL.md -> injects complete instructions into current context
Claude reads the [instruction manual] in SKILL.md -> generates step-by-step execution plan
Call tools (like reading files), run scripts (like Python data processing), call MCP (like sending Slack messages)
Claude checks output results -> if error occurs, automatically retry according to error handling guidelines in Skill
Real-World Example: Automated Expense Approval Agent
We'll demonstrate the workflow using a concrete corporate expense reimbursement scenario
User Instruction:
"Help me process the travel expenses in travel_expenses.csv, submit compliant ones to the finance system, and email me for any non-compliant ones."
Installed Skill:
expense-manager (Expense Management Expert)
Process employee reimbursement data, execute compliance checks and auto-submit
Detailed Step-by-Step Breakdown
Claude Thinks:
Claude thinks: User mentioned [process reimbursement] and [CSV], scans expense-manager description: *[process employee reimbursement data, execute compliance checks and auto-submit]*.
Action:
Claude decides to load expense-manager/SKILL.md.
Context adds detailed rules for this Skill, e.g., *[meal limit $75/person],[must mask credit card numbers]*.
Claude Thinks:
Claude plans: According to SKILL.md instructions, can't directly send CSV to finance, must clean data first.
Action:
Calls Python tool to run expense-manager/scripts/clean_pii.py.
*Script function:* Automatically identifies and masks credit card numbers in CSV (PII Redaction).
Claude Thinks:
Action (Logic Judgment): Claude reads cleaned data, compares line by line with policy rules in SKILL.md.
Action:
*Anomaly found:* A $120 dinner expense exceeds the $75 limit.
System identifies non-compliant items and marks for manual handling.
Claude Thinks:
Branch A (Compliant data):
Action:
Action (MCP call): Through SQL MCP Server, insert compliant data into company database INSERT INTO finance_db ...
Policy-compliant data automatically enters financial workflow.
Claude Thinks:
Branch B (Non-compliant data):
Action:
Action (Tool call): Generate explanation email based on template templates/rejection_email.txt in SKILL.md.
Action (MCP call): Send email to user through Gmail MCP interface.
Claude Thinks:
Claude self-reflection: [Did database insert succeed? Was email sent?]
Action:
Action: Check status code returned by MCP. If Success, reply to user with final report.
Provide complete processing results and next step recommendations.
Technical Details Under the Hood
Include a "Developer Note" section explaining why this workflow is efficient
Intelligent Recognition
Semantic understanding automatically matches the most suitable skills
Progressive Loading
On-demand loading optimizes context usage efficiency
Automatic Verification
Self-correction ensures execution result accuracy