一键导入
gaia-patterns
Use when building or modifying Gaia components -- agents, skills, hooks, CLI tools, or routing config
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when building or modifying Gaia components -- agents, skills, hooks, CLI tools, or routing config
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when constructing or interpreting the approval handoff envelope between subagent and orchestrator -- sealed_payload schema, approval_id format, APPROVAL_REQUEST contract shape, and reading a granted approval from the DB
Use when producing any agent response
Use when classifying any operation before executing it, or deciding whether user approval is required
Use when a mutative command was blocked by the hook and you need to request user approval, or when presenting a plan for a T3 operation before executing it
Use when the user wants to build, design, or extend a diagram — an architecture overview, a timeline, a planner board, a flow diagram, a presentation, a comparison, or a mind-map — as a portable, data-driven deck rendered from plain YAML. Triggers — "build a diagram", "architecture diagram", "diagram deck", "timeline", "flow diagram", "planner board", "add a page/section/component to the diagram".
Use when the user wants something to run routinely / on a schedule rather than once now -- "tarea programada", "rutinariamente", "cada mañana", "cada N horas", "todas las noches", "schedule", "cron". Covers mounting, structuring, and running an unattended headless task that reports back, plus consuming its reports. NOT for a live in-session agentic loop (that is agentic-loop).
| name | gaia-patterns |
| description | Use when building or modifying Gaia components -- agents, skills, hooks, CLI tools, or routing config |
| metadata | {"user-invocable":false,"type":"domain"} |
Construction patterns for building Gaia components. Every component type follows a discoverable pattern -- read 2-3 existing examples before creating a new one. For the full component inventory, see reference.md.
1. User sends prompt
|
2. Orchestrator routes to agent (DB-backed surface_routing table)
|
3. Pre-Tool Hook (pre_tool_use.py)
+-- Inject project context (from ~/.gaia/gaia.db via context_provider.py)
+-- Load skills from frontmatter
+-- Validate permissions
|
4. Agent executes -> returns agent_contract_handoff
|
5. Post-Tool Hook -> audit + metrics
|
6. Orchestrator processes plan_status (APPROVAL_REQUEST / NEEDS_INPUT / COMPLETE)
Entry points (hooks/*.py) are stdin/stdout glue only. All logic lives in the adapter layer.
hooks/pre_tool_use.py -- reads stdin, calls adapter, writes stdout
-> adapters/claude_code.py -- parses event, dispatches to modules
-> modules/security/* -- blocked_commands, mutative_verbs
-> modules/context/* -- context_injector, contracts_loader
-> modules/agents/* -- contract_validator, skill_injection
To add a new module: Write module in modules/<package>/, import and call it from the relevant adapter method. Modules receive parsed context and return results; they never read stdin or write stdout.
To add a new hook entry point: Create hooks/<event_name>.py, register it in build/<plugin>.manifest.json, add matchers. The entry point reads stdin JSON, calls the adapter, and prints the response.
---
name: agent-name
description: Routing label -- triggers when orchestrator sees matching intent
tools: Read, Edit, Write, Glob, Grep, Bash # restrict per domain
model: inherit
permissionMode: acceptEdits # required for most agents; omit only for orchestrator and read-only agents
skills:
- agent-protocol # always first
- security-tiers # always second
- command-execution # if agent runs commands
- domain-skill # agent's domain patterns
---
Identity (1-2 paragraphs): domain, output format. Scope: CAN DO / CANNOT DO -> DELEGATE table. Domain Errors: agent-specific errors only.
Agents get instantiated as: identity (.md) + skills (injected from frontmatter) + project-context (filtered by DB-backed contracts from project_context_contracts) + orchestrator request.
The DB-backed surface_routing table maps user intent to agents. The source of truth is each agent's routing: frontmatter block (agents/*.md): surface, adjacent_surfaces, signals (commands/artifacts), required_checks, optional sub_surfaces. Keywords were retired as a signal source -- the matcher (tools/context/surface_router.py::_score_surface) scores commands and artifacts only; a legacy keywords key in a signals block is ignored by scoring. The surface's intent is the agent's description; contract_sections derives from project_context_contracts.read. tools/scan/seed_surface_routing.py seeds the table at install time (mirror of seed_contract_permissions.py); tools/context/surface_router.py reads it via load_surface_routing_config().
To add a surface: Add a routing: block to the owning agent's frontmatter, register the agent in build/gaia.manifest.json, re-run gaia install, and update the surface-router tests.
To add a signal: Add command/artifact patterns to the owning agent's routing: block.
CLI tools live in bin/ and are registered in package.json bin field. Pattern: parse args, resolve paths (follow symlinks to source), run checks, exit with code. gaia doctor is the diagnostic model -- read it first.
When you modify any Gaia component (hook, skill, agent definition, routing config, security rule), check if existing reference docs describe that component's behavior. If drift exists, report it via cross_layer_impacts in your agent_contract_handoff. The orchestrator then decides whether to dispatch a documentation update task.
Do NOT update docs yourself -- your job is to flag the drift and let the orchestrator choose the next action.
Examples of drift to flag:
_is_protected() paths in adapters/claude_code.py → check security-tiers/SKILL.md for path documentationgaia-patterns/reference.md for agents tablesecurity-tiers and agent-protocol referencesFormat: In cross_layer_impacts, list the doc file and the behavior change, e.g.:
"cross_layer_impacts": [
"security-tiers/SKILL.md: _is_protected() now excludes .claude/settings.local.json"
]