Skip to content

Commit af3bf4c

Browse files
claudeanandgupta42
authored andcommitted
Implement AI Teammate training system and Deep Research mode
Core training infrastructure built on top of existing memory system: Training Store & Types: - TrainingStore wraps MemoryStore with training-specific conventions - Four knowledge kinds: pattern, rule, glossary, standard - Structured metadata (applied count, source, acceptance tracking) - Training blocks stored in .opencode/memory/training/ (git-committable) - One person teaches, whole team benefits via git Training Tools: - training_save: Save learned patterns, rules, glossary, standards - training_list: List all learned knowledge with applied counts - training_remove: Remove outdated training entries Training Skills: - /teach: Learn patterns from example files in the codebase - /train: Learn standards from documents or style guides - /training-status: Dashboard of all learned knowledge System Prompt Injection: - Training knowledge injected alongside memory at session start - Structured by kind: rules first, then patterns, standards, glossary - Budget-limited to 6000 chars to control prompt size - Zero LLM calls on startup — just reads files from disk Deep Research Agent Mode: - New "researcher" agent for multi-step investigations - 4-phase protocol: Plan → Gather → Analyze → Report - Read-only access to all warehouse, schema, FinOps tools - Structured reports with evidence, root causes, action items Agent Awareness: - All agent prompts updated with training awareness section - Agents offer to save corrections as rules when users correct behavior - Training tools permitted in all agent modes Tests: - 88 new tests across 5 test files (types, store, prompt, tools, integration) - All tests standalone (no Instance dependency) - Full lifecycle tests: save → list → format → inject → remove - Edge cases: budget limits, meta roundtrips, coexistence with memory https://claude.ai/code/session_01V17Kk3qCZFp9ZJiuNYucoq
1 parent 8694dc0 commit af3bf4c

25 files changed

Lines changed: 2706 additions & 122 deletions

File tree

.opencode/skills/teach/SKILL.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
name: teach
3+
description: Teach your AI teammate a pattern by showing it an example file from your codebase
4+
---
5+
6+
# Teach
7+
8+
## Purpose
9+
Learn a reusable pattern from an example file. The user shows you a well-written artifact (model, query, config), and you extract the patterns worth following.
10+
11+
## Workflow
12+
13+
1. **Identify the file**: The user provides a file reference (e.g., `@models/staging/stg_orders.sql`). Read the file.
14+
15+
2. **Analyze patterns**: Extract the structural patterns, NOT the specific content. Focus on:
16+
- File structure and organization (sections, ordering)
17+
- Naming conventions (prefixes, suffixes, casing)
18+
- SQL patterns (CTE vs subquery, join style, column ordering)
19+
- dbt conventions (materialization, tests, config blocks)
20+
- Common boilerplate (headers, comments, imports)
21+
- Data type choices
22+
- Error handling patterns
23+
24+
3. **Present findings**: Show the user what you learned in a structured list. Be specific:
25+
- Good: "Column order: keys first, then dimensions, then measures, then timestamps"
26+
- Bad: "Good column ordering"
27+
28+
4. **Ask for confirmation**: Let the user confirm, modify, or reject your findings before saving.
29+
30+
5. **Save via training_save**: Use the `training_save` tool with:
31+
- `kind`: "pattern"
32+
- `name`: A descriptive slug (e.g., "staging-model", "incremental-config")
33+
- `content`: The extracted patterns as a concise, actionable checklist
34+
- `scope`: "project" (default — shared with team via git)
35+
- `source`: The file path you learned from
36+
- `citations`: Reference to the source file
37+
38+
## Important Guidelines
39+
40+
- Extract PATTERNS, not content. "Use `{{ source() }}` macro" is a pattern. "Query the orders table" is content.
41+
- Keep it concise — max 10 bullet points per pattern. If more are needed, split into multiple patterns.
42+
- Use the file's actual conventions, don't impose your own preferences.
43+
- If the file doesn't have clear patterns worth learning, say so honestly.
44+
- Do NOT make any LLM calls beyond the normal conversation flow — pattern extraction happens in your analysis, not via separate API calls.
45+
46+
## Usage Examples
47+
48+
```
49+
/teach @models/staging/stg_orders.sql
50+
/teach staging-model @models/staging/stg_customers.sql
51+
/teach @dbt_project.yml
52+
```
53+
54+
If the user provides a name (first argument before the @file), use that as the pattern name. Otherwise, infer a name from the file type and purpose.

.opencode/skills/train/SKILL.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
name: train
3+
description: Train your AI teammate on team standards from a document or style guide
4+
---
5+
6+
# Train
7+
8+
## Purpose
9+
Learn team standards and conventions from a document (style guide, review checklist, coding standards, etc.). Extracts actionable rules and saves them as training.
10+
11+
## Workflow
12+
13+
1. **Get the document**: The user provides either:
14+
- A file reference: `@docs/sql-style-guide.md`
15+
- A URL: The full URL to fetch (use webfetch tool)
16+
- Inline text: Pasted directly in the chat
17+
18+
2. **Read and analyze**: Parse the document and extract:
19+
- Specific, enforceable rules (naming, formatting, prohibited patterns)
20+
- Review criteria and checklists
21+
- Glossary terms and definitions
22+
- Architectural standards
23+
24+
3. **Categorize**: Group findings by training kind:
25+
- `rule` — Specific do/don't rules (e.g., "Never use SELECT *")
26+
- `standard` — Broader conventions (e.g., "SQL style guide compliance")
27+
- `glossary` — Term definitions (e.g., "ARR = Annual Recurring Revenue")
28+
29+
4. **Present summary**: Show the user what you extracted:
30+
- Number of rules, standards, and glossary terms found
31+
- Preview of each item
32+
- Ask for confirmation before saving
33+
34+
5. **Save via training_save**: Save each item using the `training_save` tool. For documents with many rules, consolidate related rules into logical groups (e.g., "sql-naming-rules" with 5 rules, rather than 5 separate entries).
35+
36+
## Important Guidelines
37+
38+
- Only extract ACTIONABLE items. Skip vague guidance like "write clean code."
39+
- Consolidate related rules into single training entries to avoid clutter.
40+
- Preserve the original wording when it's specific and clear.
41+
- If the document is too large, focus on the most impactful rules.
42+
- Always use `scope: project` unless the user specifies global.
43+
- Do NOT make any extra LLM calls — analysis happens in the normal conversation flow.
44+
45+
## Usage Examples
46+
47+
```
48+
/train @docs/sql-style-guide.md
49+
/train https://wiki.company.com/data-team/review-checklist
50+
/train (then paste content inline)
51+
```
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
name: training-status
3+
description: Show what your AI teammate has learned — patterns, rules, glossary, and standards
4+
---
5+
6+
# Training Status
7+
8+
## Purpose
9+
Display a comprehensive overview of everything your AI teammate has been trained on.
10+
11+
## Workflow
12+
13+
1. **Fetch all training**: Use the `training_list` tool with no filters to get all training entries.
14+
15+
2. **Present the dashboard**: Format the output as a clean status report:
16+
17+
```
18+
Training Status
19+
20+
Patterns: X (staging-model, incremental-config, ...)
21+
Rules: X (no-float, no-select-star, ...)
22+
Glossary: X (arr, mrr, churn-date, ...)
23+
Standards: X (sql-style-guide, review-checklist, ...)
24+
25+
Recent Training:
26+
- 2 days ago: Learned rule "no-float" (from user correction)
27+
- 5 days ago: Learned pattern "staging-model" (from stg_orders.sql)
28+
- 1 week ago: Loaded standard "sql-style-guide" (from docs/sql-style.md)
29+
30+
Most Applied:
31+
- "staging-model" pattern — applied 12 times
32+
- "no-float" rule — applied 8 times
33+
```
34+
35+
3. **Offer actions**: After showing status, suggest:
36+
- `/teach` to learn new patterns
37+
- `/train` to load standards from documents
38+
- `training_remove` to remove outdated entries
39+
- `training_list` with filters for detailed views
40+
41+
## Usage
42+
43+
```
44+
/training-status
45+
```

0 commit comments

Comments
 (0)