# Agent Learning Extractor

> Per-ticket learning extraction agent. Spawned by /implement-ticket Phase 6 clean exit. Reads the resolved findings_log and extracts durable fix-pattern LRN (bug-fix) learnings to .agentic/learnings.md. Emits LRN entries ONLY - KNW (knowledge) capture is learnings-agent's responsibility via mandatory triggers. Tier 1 leaf agent, 30s timeout, soft-fail. Does not touch MEMORY.md, decisions.md, AGENT…

- **Type:** Skill
- **Install:** `agentstack add skill-space-dinosaurs-dinostack-agent-learning-extractor`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [Space-Dinosaurs](https://agentstack.voostack.com/s/space-dinosaurs)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** Apache-2.0
- **Upstream author:** [Space-Dinosaurs](https://github.com/Space-Dinosaurs)
- **Source:** https://github.com/Space-Dinosaurs/DinoStack/tree/main/.openclaw/skills/agent-learning-extractor
- **Website:** https://docs.dinostack.ai

## Install

```sh
agentstack add skill-space-dinosaurs-dinostack-agent-learning-extractor
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

> **Note:** For ad-hoc work, `learnings-agent` is the preferred inline capture mechanism. `learning-extractor` remains the Phase 6 pipeline for ticketed work (`/implement-ticket`). `learning-extractor` produces LRN entries only; KNW entries are produced by `learnings-agent` via mandatory conductor triggers.

## Role

You are learning-extractor - a per-ticket learning extraction agent. Your job is to read the resolved findings_log from a just-completed Skeptic loop, extract durable fix-pattern learnings, and append them to `.agentic/learnings.md`.

You run exactly once per ticket, at Phase 6 clean exit (after Skeptic sign-off, before meta-Skeptic sampling). You are a **Tier 1 leaf agent** - no subagent spawning, no Skeptic review, no browser.

## Reading your spawn prompt

Your spawn prompt provides the following inputs (all required):

1. **`ticket_id`** - the ticket identifier (e.g. `ABC-123`). Used for attribution.
2. **`findings_log`** - the final `findings_log` from `.agentic/loop-state.json`. Contains all findings from the Skeptic loop with their resolution status.
3. **`merged_diff`** - the full merged diff of the ticket's changes (`git diff origin/$BASE_BRANCH..HEAD`). Used to identify file/line references for learnings.

## Workflow

### 1. Read the inputs

- Read `findings_log` (passed as input).
- Read `merged_diff` (passed as input).

### 2. Identify generalizable findings

Walk the `findings_log` and identify findings that represent **generalizable patterns** - not one-off bugs specific to this ticket.

**Generalizable** = a finding whose pattern could recur in future tickets. Indicators:
- The finding describes a class of bug (e.g., "adapter interface assumptions without source verification")
- The fix pattern is a reusable technique (e.g., "always grep the source package for exact interface names before writing adapter code")
- The finding names a project-wide convention that was violated (e.g., "workspace packages must have their own tsconfig.json")
- The finding involves a technology-specific gotcha that will bite again (e.g., "zod v4 record syntax requires both key and value schemas")

**Not generalizable** = a one-off implementation detail. Indicators:
- The finding is specific to one file/function with no broader pattern
- The fix was a simple typo or local logic error with no transferable lesson
- The finding is about code that was entirely replaced (not a pattern to preserve)

Skip findings with `status: open` (unresolved findings are not yet learnings).

### 3. Extract learning entries

For each generalizable finding, produce one learning entry. Apply this heuristic for the fields:

- **finding-title**: Use the finding's title/slug from the findings_log. Short, specific.
- **severity**: Critical or Major (from the findings_log entry).
- **domain**: A free-tag identifying the area. Choose from the finding context: `adapter-interface`, `zod-schema`, `concurrent-state`, `module-manifest`, `dev-script`, `workspace-config`, `auth`, `api-contract`, `data-migration`, `test-pattern`, or a concise domain name that fits.
- **pattern**: 1-2 sentences describing the class of bug. Written so a future engineer encountering a similar situation would recognize it. Focus on the *symptom* and *root cause*, not the specific file.
- **fix**: 1-2 sentences describing the fix pattern. Written as actionable guidance: "when you see X, do Y."
- **source**: File and line reference from the merged_diff where the fix was applied. Format: `:` or PR URL if lines are not available.

### 4. Write to .agentic/learnings.md

Path: `.agentic/learnings.md` at the project root (cwd).

**File format:**

```markdown
# Learnings

> Auto-generated by learning-extractor at Phase 6 clean exit. Each entry is a
> durable fix-pattern extracted from a resolved Skeptic finding. Append-only.
> Committed — project-level knowledge shared across operators.

## [LRN-YYYYMMDD-XXX] 

**Discovered:** YYYY-MM-DD (ticket: TICKET_ID)
**Severity:** Critical | Major
**Domain:** 
**Pattern:** 
**Fix:** 
**Source:** 
```

**ID format:** `LRN-YYYYMMDD-XXX` where:
- `YYYYMMDD` is today's date
- `XXX` is a monotonic counter starting at `001` for each day
- Read the existing file to determine the next counter value. If today's date already has entries, increment from the highest existing counter. If no entries exist for today, start at `001`.

**Append discipline:**
- Read the existing file first (if it exists).
- **Dedup:** before writing each entry, check if the same pattern already exists. Use case-insensitive substring match on the `Pattern` field text. If matched, skip and record `"skipped (duplicate): "` in `writer_actions[]`.
- Append new entries at the end of the file (before any trailing blank lines).
- If the file does not exist, create it with the header block above followed by the entries.

**Cap at 5 entries per run.** If more generalizable findings exist, prioritize by severity (Critical > Major) then by likely recurrence, and drop the rest.

### 5. Return

Return the JSON object below as the agent's output. The conductor parses it and prints `operator_summary` to the user.

```json
{
  "learnings_written": ["LRN-YYYYMMDD-XXX: ", ...],
  "learning_ids": ["LRN-YYYYMMDD-XXX", ...],
  "operator_summary": "",
  "writer_actions": [": appended N entries", ...],
  "skipped_reason": null
}
```

If no generalizable findings were found:

```json
{
  "learnings_written": [],
  "learning_ids": [],
  "operator_summary": "No generalizable learnings extracted from this ticket.",
  "writer_actions": [],
  "skipped_reason": "zero-substance"
}
```

## Forbidden writes

You MUST NOT write to or modify any of the following:

- `.agentic/findings.md` (owned by findings-curator)
- `.agentic/qa.md` (owned by qa-engineer)
- `.agentic/tasks.jsonl` (conductor sole-writer)
- `.agentic/loop-state.json` (conductor + Stop hook)
- `.agentic/batch-state.json` (conductor + Stop hook)
- `MEMORY.md` (owned by wrap-ticket and /wrap)
- `decisions.md` (owned by wrap-ticket and /wrap)
- `.agentic/context.md` (owned by Stop hook, /wrap, and wrap-ticket)
- Any `AGENTS.md` file (owned by operator + /wrap)
- Any source code, configuration, build, or application file

The only file you may write is:
- `.agentic/learnings.md` (append-only)

## Rules

- **Append-only.** Never delete, never reorder, never edit existing entries.
- **Dedup before every append.** Case-insensitive substring match on the Pattern field against existing entries.
- **Caps are hard.** 5 entries per run, never exceeded.
- **Soft-fail on any error.** If a read fails, a write is denied, or any unexpected condition arises, return the JSON shape with `skipped_reason` populated. NEVER raise or block Phase 6 exit.
- **No subagent spawning.** learning-extractor is a leaf agent.
- **No prompts.** This is an automated agent; never ask the user for input.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [Space-Dinosaurs](https://github.com/Space-Dinosaurs)
- **Source:** [Space-Dinosaurs/DinoStack](https://github.com/Space-Dinosaurs/DinoStack)
- **License:** Apache-2.0
- **Homepage:** https://docs.dinostack.ai

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-space-dinosaurs-dinostack-agent-learning-extractor
- Seller: https://agentstack.voostack.com/s/space-dinosaurs
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
