ace/cli/skills/kayba-pipeline/stage-2-domain-context/SKILL.md
Gather domain context about the repository and agent — system prompt, tool definitions, domain docs, and behavior patterns from traces. Trigger when the user says "run stage 2", "gather context", "domain context", or when invoked by the kayba-pipeline orchestrator.
npx skillsauth add kayba-ai/agentic-context-engine kayba-stage-2-domain-contextInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Understand the agent's world — what it does, what tools it has, and what "success" looks like.
TRACES_FOLDER — path to directory containing trace JSON filesBefore reading traces, identify the framework that produced them. Read 1 trace file and check:
| Signal | Framework |
|--------|-----------|
| info.agent_info.implementation, info.environment_info, simulation.messages[] with role/tool_calls/turn_idx | tau2-bench |
| runs[].steps[] with type: "tool", lc_kwargs | LangChain / LangSmith |
| events[] with event_type, span_id, parent_id | LlamaIndex |
| choices[].message.tool_calls[] at top level | Raw OpenAI API logs |
| trace.spans[] with attributes, trace_id | OpenTelemetry / Arize / Langfuse |
Record the detected format in the output under Trace Format. All subsequent trace-reading steps use the field paths appropriate for that format.
If the format is unrecognized, note the top-level keys and structure, then proceed best-effort with field names found in the data.
Read 2-3 traces and determine if this is a single-agent or multi-agent system:
agent_info entry, one conversation thread, tool calls from one identityagent_info entries, routing tool calls (e.g., transfer_to_*, delegate_to_*), sub-conversation arrays, or distinct system prompts per agent identityIf multi-agent: document each agent separately (name, role, tools, handoff triggers) and note the routing logic. The remaining steps apply per-agent.
Use a fallback chain — stop at the first hit:
system_prompt, system_message, instructions, AGENT_INSTRUCTION, SYSTEM_PROMPT in YAML/JSON/TOML/Python/JS files.format() calls that build the system message (look in agent implementation files){TRACES_FOLDER}:
info.environment_info.policy (tau2-bench format)role: "system" in the messages arrayraw_data fields for system-level contentSYSTEM_PROMPT_STATUS: NOT_FOUND in the output and flag this for the orchestrator. Do not fabricate or guess.When found, record both the prompt content and its source location (file path + line, or trace field path).
Two-pass approach: source code first (ground truth), then traces (usage evidence).
Pass 1 — Source code discovery:
@tool, @is_tool, def tool_, function schema arrays, OpenAPI specs, tools=[] argumentsPass 2 — Trace usage evidence:
tool_calls[].name from assistant messagesrole: "tool" response to document actual output shapesReconcile the two passes:
Output the full tool inventory as a table with columns: Name, Category, Input Schema, Output Schema, Observed in Traces (Y/N), Unvalidated Rules.
data/*/policy.md, domain-specific docs)Trace selection — stratified sampling (do not just grab "5-10 random traces"):
{TRACES_FOLDER}. If <= 20, read ALL of them.termination_reason — include at least 2 per unique reasonFor each selected trace, document:
Write all findings to eval/stage2_domain_context.md:
# Domain Context
## Trace Format
- Framework: [detected framework name]
- Key field paths: [e.g., simulation.messages[], info.environment_info.policy]
## Architecture
- Type: [single-agent | multi-agent]
- [If multi-agent: agent roster with roles and handoff triggers]
## Agent Purpose
[1-2 sentence summary of what this agent does]
## System Prompt
- **Source**: [file path + line, or trace field path, or NOT_FOUND]
- **Status**: [verbatim | reconstructed | not_found]
[The system prompt content, or "NOT_FOUND — downstream stages should account for missing system prompt"]
## Tools
| Tool | Category | Input Schema | Output Schema | In Traces? | Unvalidated Rules |
|------|----------|-------------|---------------|------------|-------------------|
| tool_name | READ/WRITE/GENERIC | `{param: type}` | `{field: type}` | Y/N | "API does not check X" |
### Tools available but never called in traces
- [tool_name — why it matters]
## Domain Rules
[Key business rules, constraints, policies the agent must follow]
## Behavior Patterns
### Success patterns
- [pattern 1]
### Failure patterns
- [pattern 1]
### Policy violation patterns
- [violation with frequency: N/M turns]
### Error patterns
| Error | Frequency | Root cause |
|-------|-----------|------------|
| error string | N traces | cause |
### User feedback signals
- [signal 1]
eval/stage2_domain_context.mddevelopment
# ACE — Learn from Traces This skill ships `learn_from_traces.py`, a script that reads OpenClaw session transcripts, feeds them through the ACE learning pipeline, and writes an updated skillbook to disk. ## Usage ```bash python learn_from_traces.py [OPTIONS] [FILES...] ``` The script auto-discovers new sessions from `~/.openclaw/agents/<agent>/sessions/` and only processes files that haven't been processed before. Processed filenames are tracked in `ace_processed.txt`. ## Options | Flag |
devops
Implement the approved fixes from the action plan and log all changes. Trigger when the user says "run stage 7", "implement fixes", "apply action plan", or when invoked by the kayba-pipeline orchestrator. Requires eval/action_plan.md to exist.
testing
Human-In-The-Loop gate that presents the action plan with full context, collects an informed approval/modification/rejection decision, and records the outcome. Trigger when the user says "run stage 6", "HITL review", "approve action plan", or when invoked by the kayba-pipeline orchestrator. Requires eval/action_plan.md and eval/baseline_metrics.md to exist.
development
Triage each insight into discard/code-fix/prompt-fix and produce a prioritized action plan with specific recommendations. Trigger when the user says "run stage 5", "make action plan", "triage skills", or when invoked by the kayba-pipeline orchestrator. Requires eval outputs from stages 1-4.