Practical AI Agents with Claude Code
Olivier Vitrac, PhD, HDR | olivier.vitrac@adservio.fr
November 2025
Paradigm shift: Assistants → Agents
MCP: Model Context Protocol architecture
Focus: Code auditing workflows
Advanced patterns: Agent chains & automation
Hands-on: Real-world examples
Traditional tools: static analysis (limited context)
LLM assistants: interactive but require constant guidance
AI Agents: autonomous, tool-using, goal-driven
Game changer for: code review, auditing, refactoring
By the end of this lecture, you will:
Understand assistant vs agent paradigms
Configure and use MCP tools
Build audit workflows with Claude Code
Chain agents for complex tasks
graph LR
A[Static Analysis] --> B[IDE Assistants]
B --> C[LLM Chat]
C --> D[AI Agents]
style D fill:#4CAF50
Static: Rules-based (linters, type checkers)
Assistants: Context-aware suggestions
Chat: Interactive problem-solving
Agents: Autonomous execution
Characteristics:
Waits for user prompts
Responds to explicit queries
No persistent goals
Limited tool access
Example: "Explain this function"
→ Assistant reads code, explains in natural language
Characteristics:
Goal-oriented: Given a high-level task
Autonomous: Plans and executes steps
Tool-using: Reads files, runs commands, edits code
Iterative: Learns from feedback, adapts strategy
Example: "Audit this repository for security issues"
→ Agent scans files, runs tools, generates report
| Aspect | Assistant | Agent |
|---|---|---|
| Initiative | Reactive | Proactive |
| Scope | Single turn | Multi-step |
| Tools | Read-only | Read + Write + Execute |
| Autonomy | Low | High |
| Use case | Q&A, explanations | Audits, refactoring, CI/CD |
Use Assistants for:
Quick questions
Code explanations
Documentation lookup
Use Agents for:
Code auditing
Bulk refactoring
Test generation
Dependency updates
Model Context Protocol — a standard interface for AI tools
Connects LLMs to external systems
Secure, sandboxed execution
Tool discovery and registration
Standardized input/output
graph TB
Claude[Claude Code] --> MCP[MCP Server]
MCP --> Shell[Shell Tool]
MCP --> Git[Git Tool]
MCP --> FS[Filesystem Tool]
MCP --> Custom[Custom Tools]
style Claude fill:#FF6B35
style MCP fill:#004E89
Three layers:
Client: Claude Code (AI model)
Server: Tool registry & dispatcher
Tools: Individual capabilities (shell, git, file I/O)
Security: Whitelisted commands, path restrictions
tools/mcp/config.json:
ALLOWED = {"ls", "cat", "pytest", "ruff", "flake8"}
def run(cmd):
if cmd[0] not in ALLOWED:
return {"error": f"Not allowed: {cmd[0]}"}
out = subprocess.check_output(cmd, timeout=30)
return {"stdout": out.decode()}Key: Whitelist approach prevents arbitrary code execution
Open Claude Code settings
Navigate to MCP Configuration
Point to
tools/mcp/config.json
Restart Claude Code
Verify: prompt "List available MCP tools"
Modern challenges:
Rapid development cycles
Complex dependencies
Security vulnerabilities
Technical debt accumulation
Solution: Continuous, AI-assisted auditing
mindmap
root((Code Audit))
Security
Injection risks
Unsafe APIs
Secrets
Quality
Code smells
Complexity
Duplication
Standards
Style guides
Type safety
Documentation
Reliability
Error handling
Test coverage
Edge cases
| Approach | Coverage | Context | Speed |
|---|---|---|---|
| Manual review | Low | High | Slow |
| Static analysis | Medium | Low | Fast |
| AI-assisted | High | High | Fast |
Hybrid approach: Static tools + AI reasoning
Step 1: Static analysis
Step 2: AI correlation
Role: Senior auditor
Task: Analyze ruff/flake8/bandit outputs,
correlate with code, classify by severity
Severity levels:
🔴 Red: Critical (security, data loss)
🔶 Orange: Important (maintainability, performance)
⚪ White: Minor (style, documentation)
Formats:
audit.md (human-readable)
audit.json (machine-readable,
CI/CD)
You are a senior code auditor.
Goal: Read static analysis outputs in ./out/*.txt,
correlate with repository code, and classify issues.
Classify by:
- Security (CWE/OWASP)
- Maintainability (complexity, duplication)
- Reliability (error handling, tests)
- Standards (PEP 8, typing)
Assign severity: 🔴 🔶 ⚪
Output: audit.md + audit.json
| Category | File | Issue | Severity | Fix |
|---|---|---|---|---|
| Security | db/query.py |
SQL f-strings | 🔴 | Use parameterized queries |
| Complexity | utils.py |
Cyclomatic=15 | 🔶 | Refactor into smaller functions |
| Style | main.py |
Missing docstrings | ⚪ | Add module/function docs |
Pre-commit hook:
Benefit: Block merges with critical issues
Concept: Multiple specialized agents in sequence
graph LR
A[Analysis Agent] --> B[Fix Agent]
B --> C[Review Agent]
C --> D[Test Agent]
style A fill:#FF6B35
style B fill:#F7931E
style C fill:#FDC830
style D fill:#4CAF50
Agent 1 — Detector:
Scans codebase
Identifies issues
Outputs issues.json
Agent 2 — Fixer:
Reads issues.json
Proposes patches
Creates fixes.json
Agent 3 — Validator:
Applies fixes
Runs test suite
Reports success/failure
ISO/IEC 25010 Quality Model:
Maintainability ↔︎ Code smells, complexity
Security ↔︎ CWE/OWASP vulnerabilities
Reliability ↔︎ Error handling, edge cases
Portability ↔︎ Dependencies, platform assumptions
Benefit: Align audits with industry standards
Custom audit tools:
# Tool: run_security_scan
def run_security_scan(path):
bandit_out = run_bandit(path)
safety_out = check_dependencies()
return merge_results(bandit_out, safety_out)Register in MCP config → Claude uses automatically
Track debt over time:
Generate trends:
Issues introduced vs resolved
Debt accumulation rate
Hot spots (files with recurring issues)
Task: Scan requirements.txt for vulnerabilities.
1. Check each package against CVE databases
2. Propose version upgrades (maintain compatibility)
3. Run test suite to verify upgrades
4. Output: dependency_audit.md with risk matrix
Agent autonomously:
Reads requirements.txt
Queries vulnerability DBs
Tests upgrade paths
Generates report
Prompt:
Audit src/ for PEP 8 violations.
Focus on line length, import order.
Output: style_report.md
Agent:
Runs flake8
Correlates with code context
Suggests auto-fixes
Prompt:
Scan for:
- SQL injection risks
- Unsafe eval/exec
- Hardcoded secrets
Output: security_audit.json
Agent:
Static scan with bandit
Semantic analysis for logic flaws
Generates severity matrix
Prompt:
Identify top 5 technical debt items.
Rank by: impact × remediation effort.
Propose actionable fixes.
Agent:
Calculates complexity metrics
Identifies duplication
Estimates refactoring effort
Prioritizes by ROI
Workflow:
Analyzer: Detects code smells
Refactor: Proposes fixes (preserves API)
Test: Runs full test suite
Review: Human approves or rejects
Fully automated except final approval
Be specific:
❌ "Check code quality"
✅ "Audit for PEP 8, cyclomatic complexity >10, missing type hints"
Define output format:
Request JSON for CI/CD
Request Markdown for humans
Key principles:
Scope control: MCP whitelist only safe commands
No secrets in prompts: Use env vars
Traceability: Log prompt + model version in reports
Human-in-the-loop: Review before applying fixes
AI isn't perfect:
Validate findings manually
Use static tools as ground truth
Iterate on prompts to reduce noise
Strategy: Start conservative, tune over time
✅ Assistant vs Agent paradigms ✅ MCP architecture & setup ✅ Code auditing workflows (focus) ✅ Agent chaining & standards mapping ✅ Real-world examples
Agents > Assistants for complex, multi-step tasks
MCP enables safe, powerful tool integration
Auditing is the killer app for AI agents
Hybrid approach: Static tools + AI reasoning
Human oversight: Always validate critical changes
Hands-on:
Configure MCP in your environment
Run audit on internal repo
Experiment with agent chains
Next lecture (L2):
Deep dive: Technical debt strategies
Standards compliance (ISO/IEC 25010)
Advanced audit patterns
MCP Docs: [link to MCP specification]
Claude Code: [Anthropic docs]
Audit templates:
lectures/lecture1_agents/pages/
Example repo:
playground/ (if provided)
Contact: Olivier Vitrac, PhD, HDR olivier.vitrac@adservio.fr
Repository:
lectures/lecture1_agents/