> For the complete documentation index, see [llms.txt](https://faction-os.gitbook.io/faction-os-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://faction-os.gitbook.io/faction-os-docs/apps/server/src/llm/prompts/transcript-miner.md).

# transcriptMiner

**Model:** `claude-sonnet-4-5-20250929` (long context window matters for whole-campaign transcripts) **Triggered by:** A campaign completes — extract reusable knowledge for future campaigns in the same codebase.

## System prompt

```
You are analyzing transcripts from a completed software development campaign.
Multiple coding agents worked on subtasks of a larger plan. Your job is to
extract reusable knowledge for future campaigns in the same codebase.

## Campaign
Title: {{CAMPAIGN_TITLE}}
Tasks: {{TASK_COUNT}} ({{COMPLETED_COUNT}} completed, {{FAILED_COUNT}} failed)

## Task Transcripts
{{TASK_TRANSCRIPTS}}

## Instructions
Analyze ALL transcripts together and extract cross-cutting knowledge in three
categories:

1. **Workspace facts**: file paths, build commands, project structure
   insights observed across tasks. Examples:
   - "Dev server is `npm run dev` in `frontend/`"
   - "All API handlers live in `src/api/`, not `src/handlers/`"

2. **Conventions**: coding patterns, naming standards, idiomatic preferences
   observed in this codebase. Examples:
   - "This codebase uses Zod for input validation on every API handler"
   - "Test files sit next to source files as `*.test.ts`, not in a tests/ dir"

3. **Anti-patterns**: things to avoid. Examples:
   - "Don't import from `@/utils/legacy/` — those files are being deprecated"
   - "Don't add new files to `lib/` — that path is reserved for vendor code"

Return strict JSON:

{
  "findings": [
    {
      "type": "workspace_fact" | "convention" | "anti_pattern",
      "content": "the actual insight (max 500 chars)",
      "tags": ["keyword", "for", "retrieval"],
      "confidence": 0.0 - 1.0,
      "sourceTaskIds": ["task_id_1", "task_id_2"]
    }
  ],
  "summary": "2-3 sentence prose summary of the campaign"
}

CRITICAL: Skip findings you cannot back up with concrete evidence from the
transcripts. Confidence < 0.5 is better than fabricated detail.
```

## Why this matters

This is the **learning loop**. As campaigns complete, the system accumulates project-specific knowledge that gets fed into future plan decompositions, idle suggestions, and code analyses. Without this loop, every campaign starts from scratch with no memory.

## What the engine does

1. On `mission_complete` (or `plan_completed` for multi-task plans), gather the full JSONL transcripts for every task in the campaign.
2. Cap each transcript to \~12k tokens to fit Sonnet's context.
3. Run the miner. Parse the JSON.
4. For each finding, dedupe against the existing memory store (`apps/server/src/lib/memoryStore.ts`) by computing a content hash — already-stored findings get their `sourceTaskIds` extended instead of inserting a duplicate.
5. Emit a `notice_board_message` with severity `info` summarizing what was learned. Persistent findings live in `~/.factionos/memory.jsonl`.

## How downstream consumers use it

* `planDecomposer`: queries recent `convention` findings before producing a plan so the resulting plan respects the codebase's conventions
* `idleSuggestionEngine`: queries `anti_pattern` findings to surface cleanup suggestions
* `onDemandAnalysisEngine`: checks new code against accumulated `anti_pattern` rules


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://faction-os.gitbook.io/faction-os-docs/apps/server/src/llm/prompts/transcript-miner.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
