architectural-forensics

Master protocol for deconstructing agent frameworks to inform derivative system architecture. Use when (1) analyzing an agent framework's codebase comprehensively, (2) comparing multiple frameworks to select best practices, (3) designing a new agent system based on prior art, (4) documenting architectural decisions with evidence, or (5) conducting technical due diligence on AI agent implementations. This skill orchestrates sub-skills for data substrate, execution engine, cognitive architecture, and synthesis phases.

$ Installer

git clone https://github.com/Dowwie/agent_framework_study /tmp/agent_framework_study && cp -r /tmp/agent_framework_study/.claude/skills/architectural-forensics ~/.claude/skills/agent_framework_study

// tip: Run this command in your terminal to install the skill


name: architectural-forensics description: Master protocol for deconstructing agent frameworks to inform derivative system architecture. Use when (1) analyzing an agent framework's codebase comprehensively, (2) comparing multiple frameworks to select best practices, (3) designing a new agent system based on prior art, (4) documenting architectural decisions with evidence, or (5) conducting technical due diligence on AI agent implementations. This skill orchestrates sub-skills for data substrate, execution engine, cognitive architecture, and synthesis phases.

Architectural Forensics Protocol

Deconstruct agent frameworks to inform derivative system architecture.

Mission

Distinguish between software engineering decisions (how it runs) and cognitive architecture decisions (how it thinks) to extract reusable patterns for new systems.

Quick Start

# 1. Map the codebase (uses codebase-mapping skill's script)
python .claude/skills/codebase-mapping/scripts/map_codebase.py /path/to/framework --output codebase-map.json

# 2. Run analysis via the command
/analyze-frameworks

Protocol Phases

Phase 1: Engineering Chassis

Analyze the software substrate. See references/phase1-engineering.md for detailed guidance.

AnalysisFocus FilesOutput
Data Substratetypes.py, schema.py, state.pyTyping strategy, mutation patterns
Execution Enginerunner.py, executor.py, agent.pyAsync model, control flow topology
Component Modelbase_*.py, interfaces.pyAbstraction depth, DI patterns
Resilienceexecutor.py, try/except blocksError propagation, sandboxing

Phase 2: Cognitive Architecture

Extract agent "business logic". See references/phase2-cognitive.md for detailed guidance.

AnalysisFocus FilesOutput
Control Loopagent.py, loop.pyReasoning pattern, step function
Memorymemory.py, context.pyContext assembly, eviction policies
Tool Interfacetool.py, functions.pySchema generation, error feedback
Harness-Model Protocolllm.py, adapters/, stream.pyWire format, tool call encoding, agentic primitives
Multi-Agentorchestrator.py, router.pyCoordination model, state sharing

Phase 3: Synthesis

Generate actionable outputs:

  1. Best-of-Breed Matrix → Framework comparison table
  2. Anti-Pattern Catalog → "Do Not Repeat" list
  3. Reference Architecture → New framework specification

Execution Workflow

┌─────────────────────────────────────────────────────────┐
│                    For Each Framework                    │
├─────────────────────────────────────────────────────────┤
│  1. codebase-mapping                                    │
│       ↓                                                 │
│  2. Phase 1 Analysis (parallel)                         │
│     ├── data-substrate-analysis                         │
│     ├── execution-engine-analysis                       │
│     ├── component-model-analysis                        │
│     └── resilience-analysis                             │
│       ↓                                                 │
│  3. Phase 2 Analysis (parallel)                         │
│     ├── control-loop-extraction                         │
│     ├── memory-orchestration                            │
│     ├── tool-interface-analysis                         │
│     ├── harness-model-protocol                          │
│     └── multi-agent-analysis (if applicable)            │
└─────────────────────────────────────────────────────────┘
        ↓
┌─────────────────────────────────────────────────────────┐
│                      Synthesis                           │
├─────────────────────────────────────────────────────────┤
│  4. comparative-matrix                                   │
│  5. antipattern-catalog                                  │
│  6. architecture-synthesis                               │
└─────────────────────────────────────────────────────────┘

Quick Analysis (Single Framework)

For rapid assessment, run the minimal path:

codebase-mapping → execution-engine-analysis → control-loop-extraction → tool-interface-analysis

Output Directory Structure

forensics-output/                    # Working/intermediate files
├── .state/
│   ├── manifest.json
│   └── {framework}.state.json
└── frameworks/
    └── {framework}/
        ├── codebase-map.json
        ├── phase1/*.md
        └── phase2/*.md

reports/                             # Final deliverables
├── frameworks/
│   └── {framework}.md               # Framework summary
└── synthesis/
    ├── comparison-matrix.md
    ├── antipatterns.md
    ├── reference-architecture.md
    └── executive-summary.md

State Management & Resumption

The protocol is designed to be stateful and resumable.

  • Idempotency: The Orchestrator tracks progress in manifest.json and will skip frameworks marked as completed.
  • Clean Slate Resumption: If a run is interrupted, frameworks marked as in_progress are considered "stale". Use python scripts/state_manager.py reset-running to move them back to pending and delete their partial output directories, ensuring a clean restart for those items.

Agent Orchestration

This skill uses a 4-tier hierarchy of specialized agents for context efficiency:

Orchestrator
    │
    └── Framework Agents (parallel, one per framework)
            │
            └── Skill Agents (parallel, one per skill) [COORDINATORS]
                    │
                    └── Reader Agents (parallel, one per file cluster) [EXTRACTORS]
                            │
                            └── Synthesis Agent (cross-framework synthesis)

Agent Roles

AgentContext BudgetReadsProduces
Orchestrator~10KState filesCoordination decisions
Framework Agent~50KSkill outputsFramework summary report
Skill Agent~25KCluster extractsSkill analysis report
Reader Agent~20K1-5 source filesJSON extract (~2K)
Synthesis Agent~40KAll framework reportsComparison matrix, architecture spec

Key Innovation: Cluster-Based Reading

Reader Agents read file clusters (1-5 related files) rather than individual files:

  • Clusters are grouped by relationship: hierarchy, module cohort, type+usage, interface+impl
  • Cross-file patterns (inheritance, imports, shared state) are captured in the extract
  • This enables understanding architectural patterns that span multiple files

See:

  • references/orchestrator-agent.md — Top-level coordination
  • references/framework-agent.md — Per-framework analysis coordination
  • references/skill-agent.md — Skill coordination and cluster assignment
  • references/reader-agent.md — File cluster extraction
  • references/synthesis-agent.md — Cross-framework synthesis

Sub-Skill Reference

SkillPurposeKey Outputs
codebase-mappingRepository structureFile tree, dependencies, entry points
data-substrate-analysisType systemTyping strategy, serialization
execution-engine-analysisControl flowAsync model, event architecture
component-model-analysisExtensibilityAbstraction patterns, DI
resilience-analysisError handlingError propagation, sandboxing
control-loop-extractionReasoning loopPattern classification, step function
memory-orchestrationContext managementAssembly, eviction, tiers
tool-interface-analysisTool systemSchema gen, error feedback
harness-model-protocolLLM interface layerWire format, encoding, agentic primitives
multi-agent-analysisCoordinationHandoffs, state sharing
comparative-matrixComparisonDecision tables
antipattern-catalogTech debtDo-not-repeat list
architecture-synthesisNew designReference spec