agent-architecture-analysis by existential-birds/beagle
npx skills add https://github.com/existential-birds/beagle --skill agent-architecture-analysis| 参数 | 描述 | 必填 |
|---|---|---|
docs_path | 文档目录路径(用于现有分析) | 可选 |
codebase_path | 待分析代码库的根路径 | 必填 |
原则: 使用模式验证的输出,将自然语言输入转换为结构化的、确定性的工具调用。
搜索模式:
# 查找 Pydantic 模式
grep -r "class.*BaseModel" --include="*.py"
grep -r "TaskDAG\|TaskResponse\|ToolCall" --include="*.py"
# 查找 JSON 模式生成
grep -r "model_json_schema\|json_schema" --include="*.py"
# 查找结构化输出生成
grep -r "output_type\|response_model" --include="*.py"
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
文件模式: **/agents/*.py, **/schemas/*.py, **/models/*.py
合规标准:
| 等级 | 标准 |
|---|---|
| 强 | 所有 LLM 输出均使用带有验证器的 Pydantic/数据类模式 |
| 部分 | 部分输出有类型定义,但存在字典返回或未验证的字符串 |
| 弱 | LLM 返回原始字符串,需手动或使用正则表达式解析 |
反模式:
json.loads(llm_response)output.split() 或正则表达式解析dict[str, Any] 类型原则: 将提示词视为你控制、版本化和迭代的一等代码。
搜索模式:
# 查找嵌入式提示词
grep -r "SYSTEM_PROMPT\|system_prompt" --include="*.py"
grep -r '""".*You are' --include="*.py"
# 查找模板系统
grep -r "jinja\|Jinja\|render_template" --include="*.py"
find . -name "*.jinja2" -o -name "*.j2"
# 查找提示词目录
find . -type d -name "prompts"
文件模式: **/prompts/**, **/templates/**, **/agents/*.py
合规标准:
| 等级 | 标准 |
|---|---|
| 强 | 提示词位于单独的文件中,使用模板(Jinja2),有版本控制 |
| 部分 | 提示词作为模块常量,有一定参数化 |
| 弱 | 提示词硬编码在函数内部,仅使用 f-strings |
反模式:
f"You are a {role}..."原则: 控制历史记录、状态和工具结果如何为 LLM 格式化。
搜索模式:
# 查找上下文/消息管理
grep -r "AgentMessage\|ChatMessage\|messages" --include="*.py"
grep -r "context_window\|context_compiler" --include="*.py"
# 查找自定义序列化
grep -r "to_xml\|to_context\|serialize" --include="*.py"
# 查找令牌管理
grep -r "token_count\|max_tokens\|truncate" --include="*.py"
文件模式: **/context/*.py, **/state/*.py, **/core/*.py
合规标准:
| 等级 | 标准 |
|---|---|
| 强 | 自定义上下文格式,令牌优化,类型化事件,压缩 |
| 部分 | 具有基本结构的消息历史记录 |
| 弱 | 原始消息累积,仅使用标准 OpenAI 格式 |
反模式:
原则: 工具产生经过模式验证的 JSON,触发确定性的代码,而不是神奇的函数调用。
搜索模式:
# 查找工具/响应模式
grep -r "class.*Response.*BaseModel" --include="*.py"
grep -r "ToolResult\|ToolOutput" --include="*.py"
# 查找确定性处理器
grep -r "def handle_\|def execute_" --include="*.py"
# 查找验证层
grep -r "model_validate\|parse_obj" --include="*.py"
文件模式: **/tools/*.py, **/handlers/*.py, **/agents/*.py
合规标准:
| 等级 | 标准 |
|---|---|
| 强 | 所有工具输出都经过模式验证,处理器类型安全 |
| 部分 | 大多数工具有类型定义,部分返回宽松的字典 |
| 弱 | 工具返回任意字典,没有验证层 |
反模式:
eval() 或 exec()原则: 将执行状态(步骤、重试)与业务状态(消息、结果)合并。
搜索模式:
# 查找状态模型
grep -r "ExecutionState\|WorkflowState\|Thread" --include="*.py"
# 查找双重状态系统
grep -r "checkpoint\|MemorySaver" --include="*.py"
grep -r "sqlite\|database\|repository" --include="*.py"
# 查找状态重建
grep -r "load_state\|restore\|reconstruct" --include="*.py"
文件模式: **/state/*.py, **/models/*.py, **/database/*.py
合规标准:
| 等级 | 标准 |
|---|---|
| 强 | 包含所有执行元数据的单一可序列化状态对象 |
| 部分 | 状态存在但分散在多个系统中(内存 + 数据库) |
| 弱 | 执行状态分散,需要多次查询才能重建 |
反模式:
原则: 代理支持简单的 API 用于启动、在任何点暂停和恢复。
搜索模式:
# 查找 REST 端点
grep -r "@router.post\|@app.post" --include="*.py"
grep -r "start_workflow\|pause\|resume" --include="*.py"
# 查找中断机制
grep -r "interrupt_before\|interrupt_after" --include="*.py"
# 查找 Webhook 处理器
grep -r "webhook\|callback" --include="*.py"
文件模式: **/routes/*.py, **/api/*.py, **/orchestrator/*.py
合规标准:
| 等级 | 标准 |
|---|---|
| 强 | REST API + Webhook 恢复,可在任何点暂停,包括工具执行过程中 |
| 部分 | 存在启动/暂停/恢复功能,但仅在粗粒度点 |
| 弱 | 仅 CLI 启动,无暂停/恢复能力 |
反模式:
input() 或 confirm() 调用原则: 联系人类是一种工具调用,包含问题、选项和紧急程度。
搜索模式:
# 查找人类输入机制
grep -r "typer.confirm\|input(\|prompt(" --include="*.py"
grep -r "request_human_input\|human_contact" --include="*.py"
# 查找审批模式
grep -r "approval\|approve\|reject" --include="*.py"
# 查找结构化问题格式
grep -r "question.*options\|HumanInputRequest" --include="*.py"
文件模式: **/agents/*.py, **/tools/*.py, **/orchestrator/*.py
合规标准:
| 等级 | 标准 |
|---|---|
| 强 | 具有问题/选项/紧急程度/格式的 request_human_input 工具 |
| 部分 | 存在审批关卡,但硬编码在图结构中 |
| 弱 | 阻塞式 CLI 提示,没有基于工具的人类联系 |
反模式:
typer.confirm()原则: 自定义控制流,而非框架默认值。完全控制路由、重试、压缩。
搜索模式:
# 查找路由逻辑
grep -r "add_conditional_edges\|route_\|should_continue" --include="*.py"
# 查找自定义循环
grep -r "while True\|for.*in.*range" --include="*.py" | grep -v test
# 查找执行模式控制
grep -r "execution_mode\|agentic\|structured" --include="*.py"
文件模式: **/orchestrator/*.py, **/graph/*.py, **/core/*.py
合规标准:
| 等级 | 标准 |
|---|---|
| 强 | 自定义路由函数,条件边,执行模式控制 |
| 部分 | 框架控制流,带有一些自定义 |
| 弱 | 默认框架循环,无自定义路由 |
反模式:
原则: 上下文中的错误支持自我修复。跟踪连续错误,在达到阈值后升级。
搜索模式:
# 查找错误处理
grep -r "except.*Exception\|error_history\|consecutive_errors" --include="*.py"
# 查找重试逻辑
grep -r "retry\|backoff\|max_attempts" --include="*.py"
# 查找升级
grep -r "escalate\|human_escalation" --include="*.py"
文件模式: **/agents/*.py, **/orchestrator/*.py, **/core/*.py
合规标准:
| 等级 | 标准 |
|---|---|
| 强 | 错误在上下文中,带阈值的重试,自动升级 |
| 部分 | 错误被记录并返回,没有自动重试循环 |
| 弱 | 仅记录错误,不反馈给 LLM,任务立即失败 |
反模式:
logger.error() 而不添加到上下文原则: 每个代理职责范围狭窄,最多 3-10 个步骤。
搜索模式:
# 查找代理类
grep -r "class.*Agent\|class.*Architect\|class.*Developer" --include="*.py"
# 查找步骤定义
grep -r "steps\|tasks" --include="*.py" | head -20
# 统计每个代理的方法数
grep -r "async def\|def " agents/*.py 2>/dev/null | wc -l
文件模式: **/agents/*.py
合规标准:
| 等级 | 标准 |
|---|---|
| 强 | 3+ 个专业代理,每个具有单一职责,步骤限制 |
| 部分 | 多个代理,但部分职责范围过广 |
| 弱 | 单个“全能”代理处理所有事情 |
反模式:
原则: 工作流可从 CLI、REST、WebSocket、Slack、Webhook 等触发。
搜索模式:
# 查找入口点
grep -r "@cli.command\|@router.post\|@app.post" --include="*.py"
# 查找 WebSocket 支持
grep -r "WebSocket\|websocket" --include="*.py"
# 查找外部集成
grep -r "slack\|discord\|webhook" --include="*.py" -i
文件模式: **/routes/*.py, **/cli/*.py, **/main.py
合规标准:
| 等级 | 标准 |
|---|---|
| 强 | CLI + REST + WebSocket + Webhook + 聊天集成 |
| 部分 | 提供 CLI + REST API |
| 弱 | 仅 CLI,无程序化访问 |
反模式:
if __name__ == "__main__" 入口点原则: 代理作为纯函数:(状态, 输入) -> (状态, 输出)。代理逻辑中没有副作用。
搜索模式:
# 查找状态突变模式
grep -r "\.status = \|\.field = " --include="*.py"
# 查找不可变更新
grep -r "model_copy\|\.copy(\|with_" --include="*.py"
# 查找代理中的副作用
grep -r "write_file\|subprocess\|requests\." agents/*.py 2>/dev/null
文件模式: **/agents/*.py, **/nodes/*.py
合规标准:
| 等级 | 标准 |
|---|---|
| 强 | 不可变状态更新,副作用隔离到工具/处理器 |
| 部分 | 大部分不可变,存在一些原地突变 |
| 弱 | 状态原地突变,副作用与代理逻辑混杂 |
反模式:
state.field = new_value(突变)原则: 预先获取可能需要的数据,而不是在工作流中途获取。
搜索模式:
# 查找上下文预取
grep -r "pre_fetch\|prefetch\|fetch_context" --include="*.py"
# 查找 RAG/嵌入系统
grep -r "embedding\|vector\|semantic_search" --include="*.py"
# 查找相关文件发现
grep -r "related_tests\|similar_\|find_relevant" --include="*.py"
文件模式: **/context/*.py, **/retrieval/*.py, **/rag/*.py
合规标准:
| 等级 | 标准 |
|---|---|
| 强 | 在规划前自动预取相关测试、文件、文档 |
| 部分 | 手动传递上下文,支持设计文档 |
| 弱 | 没有预取,LLM 必须通过工具请求所有上下文 |
反模式:
| 要素 | 状态 | 备注 |
|--------|--------|-------|
| 1. 自然语言 -> 工具调用 | **强/部分/弱** | [关键发现] |
| 2. 拥有你的提示词 | **强/部分/弱** | [关键发现] |
| ... | ... | ... |
| 13. 预取上下文 | **强/部分/弱** | [关键发现] |
**总体情况**:X 强,Y 部分,Z 弱
为每个要素提供:
* 证据,包含文件:行号引用
* 显示模式的代码片段
2. 合规等级
* 强/部分/弱,并附理由
3. 差距
* 与 12-Factor 理想状态相比缺少什么
4. 建议
* 可操作的改进措施,包含代码示例
* 运行所有要素的搜索模式
* 识别每个要素的关键文件
* 记录任何现有的合规文档
2. 深入分析(按要素)
* 阅读识别出的文件
* 根据合规标准进行评估
* 使用文件路径记录证据
3. 差距分析
* 比较当前状态与 12-Factor 理想状态
* 识别存在的反模式
* 按影响优先级排序
4. 建议
* 提供可操作的改进措施
* 包含改进前/后的代码示例
* 如果存在,引用路线图
5. 总结
* 编制执行摘要表
* 突出优势和关键差距
* 建议改进的优先级顺序
| 评分 | 含义 | 行动 |
|---|---|---|
| 强 | 完全实现原则 | 维护,小优化 |
| 部分 | 部分实现,存在显著差距 | 计划改进 |
| 弱 | 最小或没有实现 | 路线图高优先级 |
每周安装次数
83
代码仓库
GitHub 星标数
45
首次出现
2026年1月20日
安全审计
安装于
gemini-cli69
codex69
opencode69
claude-code67
cursor65
github-copilot60
Reference: 12-Factor Agents
| Parameter | Description | Required |
|---|---|---|
docs_path | Path to documentation directory (for existing analyses) | Optional |
codebase_path | Root path of the codebase to analyze | Required |
Principle: Convert natural language inputs into structured, deterministic tool calls using schema-validated outputs.
Search Patterns:
# Look for Pydantic schemas
grep -r "class.*BaseModel" --include="*.py"
grep -r "TaskDAG\|TaskResponse\|ToolCall" --include="*.py"
# Look for JSON schema generation
grep -r "model_json_schema\|json_schema" --include="*.py"
# Look for structured output generation
grep -r "output_type\|response_model" --include="*.py"
File Patterns: **/agents/*.py, **/schemas/*.py, **/models/*.py
Compliance Criteria:
| Level | Criteria |
|---|---|
| Strong | All LLM outputs use Pydantic/dataclass schemas with validators |
| Partial | Some outputs typed, but dict returns or unvalidated strings exist |
| Weak | LLM returns raw strings parsed manually or with regex |
Anti-patterns:
json.loads(llm_response) without schema validationoutput.split() or regex parsing of LLM responsesdict[str, Any] return types from agentsPrinciple: Treat prompts as first-class code you control, version, and iterate on.
Search Patterns:
# Look for embedded prompts
grep -r "SYSTEM_PROMPT\|system_prompt" --include="*.py"
grep -r '""".*You are' --include="*.py"
# Look for template systems
grep -r "jinja\|Jinja\|render_template" --include="*.py"
find . -name "*.jinja2" -o -name "*.j2"
# Look for prompt directories
find . -type d -name "prompts"
File Patterns: **/prompts/**, **/templates/**, **/agents/*.py
Compliance Criteria:
| Level | Criteria |
|---|---|
| Strong | Prompts in separate files, templated (Jinja2), versioned |
| Partial | Prompts as module constants, some parameterization |
| Weak | Prompts hardcoded inline in functions, f-strings only |
Anti-patterns:
f"You are a {role}..." inline in agent methodsPrinciple: Control how history, state, and tool results are formatted for the LLM.
Search Patterns:
# Look for context/message management
grep -r "AgentMessage\|ChatMessage\|messages" --include="*.py"
grep -r "context_window\|context_compiler" --include="*.py"
# Look for custom serialization
grep -r "to_xml\|to_context\|serialize" --include="*.py"
# Look for token management
grep -r "token_count\|max_tokens\|truncate" --include="*.py"
File Patterns: **/context/*.py, **/state/*.py, **/core/*.py
Compliance Criteria:
| Level | Criteria |
|---|---|
| Strong | Custom context format, token optimization, typed events, compaction |
| Partial | Basic message history with some structure |
| Weak | Raw message accumulation, standard OpenAI format only |
Anti-patterns:
Principle: Tools produce schema-validated JSON that triggers deterministic code, not magic function calls.
Search Patterns:
# Look for tool/response schemas
grep -r "class.*Response.*BaseModel" --include="*.py"
grep -r "ToolResult\|ToolOutput" --include="*.py"
# Look for deterministic handlers
grep -r "def handle_\|def execute_" --include="*.py"
# Look for validation layer
grep -r "model_validate\|parse_obj" --include="*.py"
File Patterns: **/tools/*.py, **/handlers/*.py, **/agents/*.py
Compliance Criteria:
| Level | Criteria |
|---|---|
| Strong | All tool outputs schema-validated, handlers type-safe |
| Partial | Most tools typed, some loose dict returns |
| Weak | Tools return arbitrary dicts, no validation layer |
Anti-patterns:
eval() or exec() on LLM-generated codePrinciple: Merge execution state (step, retries) with business state (messages, results).
Search Patterns:
# Look for state models
grep -r "ExecutionState\|WorkflowState\|Thread" --include="*.py"
# Look for dual state systems
grep -r "checkpoint\|MemorySaver" --include="*.py"
grep -r "sqlite\|database\|repository" --include="*.py"
# Look for state reconstruction
grep -r "load_state\|restore\|reconstruct" --include="*.py"
File Patterns: **/state/*.py, **/models/*.py, **/database/*.py
Compliance Criteria:
| Level | Criteria |
|---|---|
| Strong | Single serializable state object with all execution metadata |
| Partial | State exists but split across systems (memory + DB) |
| Weak | Execution state scattered, requires multiple queries to reconstruct |
Anti-patterns:
Principle: Agents support simple APIs for launching, pausing at any point, and resuming.
Search Patterns:
# Look for REST endpoints
grep -r "@router.post\|@app.post" --include="*.py"
grep -r "start_workflow\|pause\|resume" --include="*.py"
# Look for interrupt mechanisms
grep -r "interrupt_before\|interrupt_after" --include="*.py"
# Look for webhook handlers
grep -r "webhook\|callback" --include="*.py"
File Patterns: **/routes/*.py, **/api/*.py, **/orchestrator/*.py
Compliance Criteria:
| Level | Criteria |
|---|---|
| Strong | REST API + webhook resume, pause at any point including mid-tool |
| Partial | Launch/pause/resume exists but only at coarse-grained points |
| Weak | CLI-only launch, no pause/resume capability |
Anti-patterns:
input() or confirm() callsPrinciple: Human contact is a tool call with question, options, and urgency.
Search Patterns:
# Look for human input mechanisms
grep -r "typer.confirm\|input(\|prompt(" --include="*.py"
grep -r "request_human_input\|human_contact" --include="*.py"
# Look for approval patterns
grep -r "approval\|approve\|reject" --include="*.py"
# Look for structured question formats
grep -r "question.*options\|HumanInputRequest" --include="*.py"
File Patterns: **/agents/*.py, **/tools/*.py, **/orchestrator/*.py
Compliance Criteria:
| Level | Criteria |
|---|---|
| Strong | request_human_input tool with question/options/urgency/format |
| Partial | Approval gates exist but hardcoded in graph structure |
| Weak | Blocking CLI prompts, no tool-based human contact |
Anti-patterns:
typer.confirm() in agent codePrinciple: Custom control flow, not framework defaults. Full control over routing, retries, compaction.
Search Patterns:
# Look for routing logic
grep -r "add_conditional_edges\|route_\|should_continue" --include="*.py"
# Look for custom loops
grep -r "while True\|for.*in.*range" --include="*.py" | grep -v test
# Look for execution mode control
grep -r "execution_mode\|agentic\|structured" --include="*.py"
File Patterns: **/orchestrator/*.py, **/graph/*.py, **/core/*.py
Compliance Criteria:
| Level | Criteria |
|---|---|
| Strong | Custom routing functions, conditional edges, execution mode control |
| Partial | Framework control flow with some customization |
| Weak | Default framework loop with no custom routing |
Anti-patterns:
Principle: Errors in context enable self-healing. Track consecutive errors, escalate after threshold.
Search Patterns:
# Look for error handling
grep -r "except.*Exception\|error_history\|consecutive_errors" --include="*.py"
# Look for retry logic
grep -r "retry\|backoff\|max_attempts" --include="*.py"
# Look for escalation
grep -r "escalate\|human_escalation" --include="*.py"
File Patterns: **/agents/*.py, **/orchestrator/*.py, **/core/*.py
Compliance Criteria:
| Level | Criteria |
|---|---|
| Strong | Errors in context, retry with threshold, automatic escalation |
| Partial | Errors logged and returned, no automatic retry loop |
| Weak | Errors logged only, not fed back to LLM, task fails immediately |
Anti-patterns:
logger.error() without adding to contextPrinciple: Each agent has narrow responsibility, 3-10 steps max.
Search Patterns:
# Look for agent classes
grep -r "class.*Agent\|class.*Architect\|class.*Developer" --include="*.py"
# Look for step definitions
grep -r "steps\|tasks" --include="*.py" | head -20
# Count methods per agent
grep -r "async def\|def " agents/*.py 2>/dev/null | wc -l
File Patterns: **/agents/*.py
Compliance Criteria:
| Level | Criteria |
|---|---|
| Strong | 3+ specialized agents, each with single responsibility, step limits |
| Partial | Multiple agents but some have broad scope |
| Weak | Single "god" agent that handles everything |
Anti-patterns:
Principle: Workflows triggerable from CLI, REST, WebSocket, Slack, webhooks, etc.
Search Patterns:
# Look for entry points
grep -r "@cli.command\|@router.post\|@app.post" --include="*.py"
# Look for WebSocket support
grep -r "WebSocket\|websocket" --include="*.py"
# Look for external integrations
grep -r "slack\|discord\|webhook" --include="*.py" -i
File Patterns: **/routes/*.py, **/cli/*.py, **/main.py
Compliance Criteria:
| Level | Criteria |
|---|---|
| Strong | CLI + REST + WebSocket + webhooks + chat integrations |
| Partial | CLI + REST API available |
| Weak | CLI only, no programmatic access |
Anti-patterns:
if __name__ == "__main__" entry pointPrinciple: Agents as pure functions: (state, input) -> (state, output). No side effects in agent logic.
Search Patterns:
# Look for state mutation patterns
grep -r "\.status = \|\.field = " --include="*.py"
# Look for immutable updates
grep -r "model_copy\|\.copy(\|with_" --include="*.py"
# Look for side effects in agents
grep -r "write_file\|subprocess\|requests\." agents/*.py 2>/dev/null
File Patterns: **/agents/*.py, **/nodes/*.py
Compliance Criteria:
| Level | Criteria |
|---|---|
| Strong | Immutable state updates, side effects isolated to tools/handlers |
| Partial | Mostly immutable, some in-place mutations |
| Weak | State mutated in place, side effects mixed with agent logic |
Anti-patterns:
state.field = new_value (mutation)Principle: Fetch likely-needed data upfront rather than mid-workflow.
Search Patterns:
# Look for context pre-fetching
grep -r "pre_fetch\|prefetch\|fetch_context" --include="*.py"
# Look for RAG/embedding systems
grep -r "embedding\|vector\|semantic_search" --include="*.py"
# Look for related file discovery
grep -r "related_tests\|similar_\|find_relevant" --include="*.py"
File Patterns: **/context/*.py, **/retrieval/*.py, **/rag/*.py
Compliance Criteria:
| Level | Criteria |
|---|---|
| Strong | Automatic pre-fetch of related tests, files, docs before planning |
| Partial | Manual context passing, design doc support |
| Weak | No pre-fetching, LLM must request all context via tools |
Anti-patterns:
| Factor | Status | Notes |
|--------|--------|-------|
| 1. Natural Language -> Tool Calls | **Strong/Partial/Weak** | [Key finding] |
| 2. Own Your Prompts | **Strong/Partial/Weak** | [Key finding] |
| ... | ... | ... |
| 13. Pre-fetch Context | **Strong/Partial/Weak** | [Key finding] |
**Overall**: X Strong, Y Partial, Z Weak
For each factor, provide:
Current Implementation
Compliance Level
Gaps
Recommendations
Initial Scan
Deep Dive (per factor)
Gap Analysis
Recommendations
Summary
| Score | Meaning | Action |
|---|---|---|
| Strong | Fully implements principle | Maintain, minor optimizations |
| Partial | Some implementation, significant gaps | Planned improvements |
| Weak | Minimal or no implementation | High priority for roadmap |
Weekly Installs
83
Repository
GitHub Stars
45
First Seen
Jan 20, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
gemini-cli69
codex69
opencode69
claude-code67
cursor65
github-copilot60
AI Elements:基于shadcn/ui的AI原生应用组件库,快速构建对话界面
67,500 周安装
Coinw合约API技能:市场数据、交易下单、止盈止损、仓位查询、账户资产
Objective-C Blocks与GCD并发编程指南:语法、用法与最佳实践
Objective-C ARC 模式详解:内存管理、循环引用与最佳实践
Blender 3D AI 助手技能:通过 Claude 与 BlenderMCP 插件实现自动化 3D 建模与渲染
context-engineering 技能:AI 上下文工程插件,提升 Claude 模型性能与开发效率
1 周安装
Claude Code Expert - 基于 Claude 的 AI 代码助手插件,提升编程效率与代码质量
1 周安装