Learn

From pipecrew-ai/pipecrew · View interactive version

Learn is an AI agent skill from the GitHub repository pipecrew-ai/pipecrew. Learn from user feedback — from a merged PR, a recorded /deliver run, a branch diff, a Claude Code session transcript, or free-form text — and propose scoped updates to the workspace's durable context docs (platform.md § Established Patterns, repo CLAUDE.md / DESIGN_SYSTEM.md / agent-context/). Pres

How to use this skill

Skill file

Description

The learning loop for PipeCrew. Converts one feedback signal → scoped doc updates so the crew gets smarter about this workspace over time.

Every source mode runs standalone — no /deliver run, session, or comment context required. Invocation from /deliver Phase 8 is one caller (see Step 7.5). text / session sources can also run workspace-less (--no-workspace): only plugin-level, run-local, out-of-scope findings are possible.

Sources accepted:

Session / free-form text are the weakest signal class — they are exploratory (most of a session is normal work, not a reusable rule). /learn biases hard toward "no update" for these: it lists what it noticed and recommends a context change only when a structural, repeatable convention is revealed. A clear "no change recommended, here's why" is a first-class, successful outcome — not a failed run.

Output scopes (tier classification for every finding):

Design system path resolution: when a finding targets a frontend repo's DESIGN_SYSTEM.md, resolve the path in this order:

  1. config.repos[repo-name].design_system_path (relative to repo.path) — the canonical source.
  2. Fallback probe: agent-context-v2/common/DESIGN_SYSTEM.md, agent-context/common/DESIGN_SYSTEM.md, agent-context/DESIGN_SYSTEM.md, docs/DESIGN_SYSTEM.md, DESIGN_SYSTEM.md.
  3. If nothing is found, the finding cannot be auto-applied — log it and point the user at /discover --resume to bootstrap the file, then re-run feedback.

Usage

/pipecrew:learn --pr=<url> [--note="..."] [--workspace=<slug>]
/pipecrew:learn --run=<run_id> [--workspace=<slug>]
/pipecrew:learn --branch=<name> [--base=<main>] [--workspace=<slug>]
/pipecrew:learn --session=<path|id|current> [--note="..."] [--workspace=<slug> | --no-workspace]
/pipecrew:learn "<free-form text>" [--workspace=<slug> | --no-workspace]

# Workspace-less (text / session only): plugin-level findings only
/pipecrew:learn "<free-form text>" --no-workspace

# Optional fix-round flags (combine with any source mode above):
/pipecrew:learn ... --fix-branch=<name>     # target a specific branch when dispatching the fix round
/pipecrew:learn ... --auto-fix              # skip the post-apply prompt — always dispatch implementers
/pipecrew:learn ... --no-fix                # skip the post-apply prompt — never dispatch implementers

Flags

| Flag | Purpose |

|------|---------|

| --pr=<url> | GitHub PR URL. Fetches review comments + commits via gh. |

| --note="..." | Optional free-form annotation. Works with any source mode (--pr, --run, --branch, or as a stand-alone supplement to the positional text). The note is passed to the feedback-learner as an extra signal alongside the structured source — the learner considers it when partitioning observations, but does NOT skip tier-classification or per-finding approval. Useful for "the architect kept picking pattern X but we always do Y" type hints that aren't visible in the run output or PR diff. |

| --run=<run_id> | A /deliver run directory name under {workspace_root}/{slug}/runs/deliver/ (legacy runs/feature/ accepted as fallback). Reads that run's corrections.md + outputs. |

| --branch=<name> | Branch name to diff (local). Base defaults to main or dev — whichever the workspace uses. |

| --base=<name> | Override the base branch for --branch mode. |

| --session=<path\|id\|current> | Learn from a Claude Code session. current = the live conversation (the orchestrator distills its salient feedback turns); a .jsonl path or a bare session id = a past transcript (collected via collect-session-feedback.js). Weakest signal class — see the source-reliability note. Composes with --note (that is the "free text + session" combination — no separate flag needed). Requires --workspace or --no-workspace (no repo to auto-detect from). |

| --workspace=<slug> | Which workspace's docs to update. Auto-detects if omitted (checks each registered workspace's config.json for repo paths that match the PR / branch). |

| --no-workspace | text / session sources only. Workspace-less run: only plugin-level, run-local, out-of-scope findings; writes under ~/.claude/pipecrew/plugin-feedback/. Rejected with --fix-branch. |

| --dry-run | Show findings + proposed updates, but skip the apply step. Implies --no-fix (a dry run never dispatches implementers). Writes nothing and never files plugin issues (drafts shown inline only). |

| --apply-all | Skip per-finding approval and apply every non-plugin-level finding. Does NOT imply --auto-fix — the fix-round prompt still runs after applies unless --auto-fix / --no-fix is also passed. Never files plugin issues (drafts listed as "saved, not filed"). |

| --fix-branch=<name> | Optional branch name to dispatch the fix round against. If omitted, the orchestrator uses each affected repo's currently checked-out branch and asks the user to confirm before dispatching. |

| --auto-fix | Skip the post-apply confirmation prompt and dispatch implementers for every approved finding's affected repo. Use with care — implementers will modify code on the resolved branch. |

| --no-fix | Skip the post-apply confirmation prompt and do NOT dispatch any implementers. Equivalent to answering "n" at the prompt. |

Examples

/pipecrew:learn --pr=https://github.com/Arabookverse-com/abvi-backoffice-service/pull/31
/pipecrew:learn --pr=https://github.com/.../pull/42 --note="we fixed the auth approach, see commit d28808e"
/pipecrew:learn --run=2026-04-16-120338-book-content-upload
/pipecrew:learn --branch=fix/contract-detail-modals --base=main
/pipecrew:learn --session=current --workspace=dal-platform          # learn from the conversation we just had
/pipecrew:learn --session=2ed98d97-4d59-4e46-... --workspace=dal-platform   # a past session by id
/pipecrew:learn --session=current --workspace=dal-platform --note="focus on the modal-vs-route discussion"
/pipecrew:learn "the plugin keeps putting details in a separate route, we always want a modal"

# With fix-round:
/pipecrew:learn --run=2026-04-15-200215-contract-view-and-list --fix-branch=feature/contract-view-and-list
/pipecrew:learn --pr=https://github.com/.../pull/31 --auto-fix
/pipecrew:learn "we never split publisher modules" --no-fix     # docs only, do not touch any branch

Instructions

CRITICAL RULES

  1. Never silently rewrite workspace / repo docs. Every proposed change is presented as a before/after diff; the user approves per finding or rejects. --apply-all still shows a summary and requires one confirmation.
  2. Never auto-apply plugin-level findings. The target would be the plugin's own prompts/templates, which are shared across all workspaces. Plugin-level findings are logged with the flag plugin-level-review-needed and handled through the Step 4 issue-draft flow.
  3. Tier classification is the first filter. Run-local findings are visible in the summary but don't become proposals. Only repo-scope, workspace-scope, and plugin-scope findings become actionable items.
  4. Log every invocation. Append to {learn_log_path} — even if every finding was rejected. The record matters.
  5. Be explicit about source reliability. PR review comments from a human reviewer are strong signal. Post-merge fix commits are strong signal (the truth shipped). Free-form user text is strong signal but filtered through the user's recall. Run corrections are moderate signal (may have been one-off decisions). A Claude Code session is the weakest signal — exploratory, mostly normal work, lots of dead ends; treat it the same class as free-form text and default to recommending no change unless a structural, repeatable convention clearly emerges.
  6. Never dispatch a fix-round implementer without explicit user consent. The fix round modifies real code on a real branch — it is the only step in /learn that touches anything outside the workspace docs. Default behavior is to ask the user (per repo, with the resolved branch named) before each dispatch. Only --auto-fix skips that gate, and only after the standard per-finding doc-approval gate has already run. --dry-run always implies --no-fix. Plugin-level findings never become fix-round dispatches (their target is the plugin, not workspace code).
  7. Never file a plugin issue without per-issue explicit consent, and never while leak-check hits are outstanding (only a user's explicit edit + confirm overrides a hit — EC-4). --apply-all, --auto-fix, --dry-run never file. --dry-run writes nothing.

PIPELINE

1. Resolve workspace ──────────── (from --workspace or auto-detect; or workspace-less; defines {learn_run_dir})
2. Collect signal ─────────────── (based on source mode — pr / run / branch / session / text)
3. Dispatch feedback-learner ──── (agent analyzes signal vs current tier-1 docs)
4. Present findings ──────────── (tier-classified, per-finding approval UX)         <- user gate
   plugin-level → issue draft → leak check → duplicate search → consent → gh issue create
5. Apply approved updates ─────── (file edits to the target tier)
6. Write learn-log entry ─────── (durable record in the workspace)
6.5. Optional fix round ──────── (per-repo implementer dispatch on the affected branch)  <- user gate
7. Report summary ────────────── (what was applied, what was flagged, what was fixed, one-line status)

Step 1: Resolve the workspace

Step 1.0 — resolve {workspace_root}: run node {plugin_dir}/scripts/workspace-root.js --get to capture the user's configured workspaces root (the same resolution /deliver and /discover use). Use {workspace_root} everywhere the steps below reference workspace paths. If the script exits non-zero (root never configured): for a text / session source, offer workspace-less mode (below); otherwise tell the user to run /discover first.

Workspace-less mode activates only for a text / session source AND (--no-workspace was passed, OR the user answers "none — plugin feedback only" when asked which workspace, OR no workspace is registered / the root is unconfigured). pr / run / branch without a resolvable workspace halt as above. In workspace-less mode: set {workspace_mode} = none; skip config validation, Step 1.5, Step 5, Step 6.5, Step 7.4, Step 7.5; reject --fix-branch with "fix round needs a workspace". Otherwise {workspace_mode} = workspace.

If --workspace=<slug> is provided, resolve it via

node {plugin_dir}/scripts/workspace-registry.js --resolve --workspace=<slug> --json

(→ {slug, path, root}; set {workspace_root} = .root). If not, enumerate the

registered workspaces with node {plugin_dir}/scripts/workspace-registry.js --list --json

and match:

Validate the resolved config via node {plugin_dir}/scripts/validate-config.js {config-path}. Halt on errors. (Skipped in workspace-less mode.)

Step 1.5 — pull shared memory (only if config.workspace.memory.enabled): before comparing the signal against the workspace's durable docs, read the team's latest so findings are proposed against current canon — node {plugin_dir}/scripts/sync-memory.js pull {workspace_root}/{slug}. Warn-only (dirty tree / fetch failure → uses local copy, never blocks /learn). Skip silently when memory is off or in workspace-less mode.

Step 1.6 — define {learn_run_dir}, {learn_log_path}, {plugin_repo} (every mode, before any collection). Compute {run_id} = {YYYY-MM-DD-HHMMSS}-{source-slug} (source-slug = pr-31, run-2026-04-16-xxx, branch-fix-foo, session-current or session-{id-prefix} (first 8 chars of the session id), or text (truncated first 24 chars of text)). Then create the directory:

{learn_run_dir} is /learn's own output dir in every mode: signal/, plugin-issues/, and learner-output.md all go there. A --run source is read-only input under {source_run_dir} (Step 2b).

Step 2: Collect the signal

Branch on the source mode. Each produces the same output shape: a signal bundle containing raw material for the learner.

2a. PR mode (`--pr`)

Comments — use the canonical collector, do NOT hand-parse gh JSON. Run the predefined script; it paginates fully, strips bot/CI noise, normalizes inline + conversation + review-summary comments into one list, and assigns stable C-n ids the learner's inventory adopts verbatim. Hand-parsing paginated JSON is the exact path by which a comment goes un-enumerated before the coverage guard can see it.

node {plugin_dir}/scripts/collect-pr-feedback.js --pr={pr-url} --out={learn_run_dir}/signal/pr-comments.json

Exit codes: 0 ok · 1 usage / bad URL · 2 gh unavailable / not authenticated / network (tell the user to gh auth login) · 3 unparseable gh output. The script prints only a one-line count to stdout — the comment bodies stay in the file, out of your context. Pass {learn_run_dir}/signal/pr-comments.json to the learner (Step 3); the learner Reads it and builds its C-n inventory from the ids the script already assigned.

Commits — fetch separately for the plugin-vs-human partition (the collector deliberately handles comments only, not the commit-authorship heuristic):

gh pr view {pr-number} --repo {org}/{repo} --json title,body,state,merged,mergeCommit,headRefName,files
gh api repos/{org}/{repo}/pulls/{pr-number}/commits

From this, compute:

1. PipeCrew-Run-Id: trailer in the commit message (definitive — stamped on every pipeline-created commit since v1.15, alongside PipeCrew-Version: which tells you which plugin build made it). A commit WITHOUT the trailer in a PR that HAS trailered commits is presumptively human.

2. Co-Authored-By: Claude trailer (weak fallback for pre-trailer history only — ANY Claude-Code-assisted commit carries it, including the user's own hand fixes, so it cannot distinguish pipeline from human-with-Claude).

3. Timestamp overlap with a /deliver run in {workspace_root}/{slug}/runs/deliver/*/checkpoints.jsonl — commits made within the run's start–end window are presumptively plugin commits.

4. Ask the user to confirm the partition before proceeding if heuristics are ambiguous.

Bundle the commit material + the canonical comment file path into the signal for the learner. Include --note verbatim if provided.

2b. Run mode (`--run`)
source_run_dir={workspace_root}/{slug}/runs/deliver/{run_id}

If runs/deliver/{run_id} is missing, try legacy runs/feature/{run_id} (note legacy path in the log entry). If neither exists, list the 5 newest runs/deliver/* ids and halt. {source_run_dir} is read-only input.

Read:

Bundle for the learner. If the run also has an associated merged PR (which you can often find by the feature's branch name), offer to also include the PR as a secondary signal source — more data usually helps.

2c. Branch-diff mode (`--branch`)
base={base or "main"}
cd {repo_path} && git log --oneline {base}..{branch} && git diff {base}...{branch}

No PR, no review comments — just the raw diff. Weakest of the structured modes (you can't distinguish "what the plugin did" from "what humans changed" without commit-level markers), but useful for learning from branches that haven't been PR'd yet.

2d. Free-form text mode (positional)

The signal IS the text. No collection step beyond capturing the user's prompt verbatim. The learner reads it alongside the current tier-1 docs and proposes what the text implies.

2e. Session mode (`--session`)

Learn from a Claude Code conversation. Two sub-cases:

--session=<path> or --session=<id> (a past transcript) — use the canonical collector; do NOT hand-walk the JSONL. The transcript is mostly noise (assistant turns, tool results, local-command stdout, system reminders, sub-agent sidechains) and a real user turn can be missed before the coverage guard sees it. The script keeps only genuine human turns, drops the rest into an audit list, and assigns stable C-n ids the learner adopts verbatim:

node {plugin_dir}/scripts/collect-session-feedback.js --session={path-or-id} --out={learn_run_dir}/signal/session.json

Exit codes: 0 ok · 1 usage / transcript-or-id not found / ambiguous id · 3 unparseable transcript. The script prints only a one-line count to stdout — the turn bodies stay in the file, out of your context. Pass {learn_run_dir}/signal/session.json to the learner (Step 3); it Reads the file and builds its C-n inventory from the ids already assigned. (A bare id resolves under ~/.claude/projects/*/{id}.jsonl; pass an absolute .jsonl path if the id is ambiguous.)

--session=current (the live conversation) — you are in the session, so do NOT try to self-read the whole transcript (it would blow the context budget). Instead, distill the salient feedback turns from the conversation you are currently in — the corrections, the "no, do it this way", the things the user repeated or insisted on — and write them yourself into {learn_run_dir}/signal/session.json in the same shape the collector emits:

{ "session": { "id": "current", "path": null, "turns": N },
  "counts": { "signal": N, "excluded": 0, "lines": 0 },
  "comments": [ { "id": "C-1", "kind": "user-turn", "ts": null, "body": "<verbatim or close-paraphrase of one feedback turn>" } ],
  "excluded": [] }

Keep comments[] to the turns that actually carry steering/feedback — skip routine "ok", "continue", "thanks". This is the cheap default path: finish a conversation, run /learn --session=current, and it proposes what (if anything) is worth persisting.

Either way, the resulting session.json is the signal bundle handed to the learner. Include --note verbatim if provided (that is the "free text + session" combination).


Step 3: Dispatch the feedback-learner agent

Tool: Agent

subagent_type: pipecrew:feedback-learner

description: "Learn from {source-mode} — {identifier}"

Prompt:

You are analyzing feedback about the {workspace.name} workspace and proposing
scoped updates to its durable context docs.
{Workspace-less: "You are analyzing feedback about the PipeCrew plugin itself; there is no workspace (workspace: none)."}

## Signal source
Mode: {pr | run | branch | session | text}
Identifier: {PR URL | run_id | branch name | <first 60 chars of text>}

## The signal

{For PR mode:}
### Review comments — canonical list (read this file)
The PR's comments are pre-collected, de-noised, and numbered at:
  {learn_run_dir}/signal/pr-comments.json
Read that file. Each entry already has a stable `C-n` id plus kind / author /
association / path:line / resolved / outdated. **Adopt those `C-n` ids verbatim
as your inventory spine** (Step 3.5) — do not renumber, drop, or merge them.
Every `C-n` in that file MUST appear in your Comment coverage table with a
disposition. (If a single comment bundles N distinct asks, keep its id and add
sub-ids C-n-a / C-n-b for the split.)

### Plugin commits ({N})
{paste commit messages + diffs}

### Post-plugin fixes ({N} commits)
{paste commit messages + diffs — these are the rich signal}

{User annotation:}
{--note contents if provided}

{For run mode:}
### Corrections captured during the run
{paste corrections.md}

### Run outputs
{paste phase-1, phase-2, phase-5-5 outputs — the artifacts that show what got produced}

{For branch mode:}
### Branch diff
{paste git log + diff}

{For text mode:}
### User feedback text
{paste verbatim}

{For session mode:}
### Session feedback — canonical list (read this file)
The session's human turns are pre-collected, de-noised, and numbered at:
  {learn_run_dir}/signal/session.json
Read that file. Each entry has a stable `C-n` id, `kind: user-turn`, and the turn
body (assistant turns, tool results, local-command echoes, system reminders and
sub-agent sidechains are already excluded). **Adopt those `C-n` ids verbatim as
your inventory spine** (Step 3.5) — do not renumber or drop them. Every `C-n`
MUST appear in your Comment coverage table with a disposition.

NOTE — this is the **weakest** signal class. A session is exploratory: most turns
are normal back-and-forth, dead ends, or one-off decisions, NOT reusable
conventions. Default each turn to `run-local` or `already-satisfied`. Only emit a
durable (`repo-durable` / `workspace-durable`) finding when a turn reveals a
**structural, repeatable** convention the user clearly wants applied beyond this
one conversation (e.g. "we ALWAYS use a modal", "NEVER split publisher modules").
When in genuine doubt, do NOT propose an update — recommend no change and say why.

## Current workspace durable docs (read and compare)

{Workspace-less: replace this whole section with: "No workspace — only `plugin-level`, `run-local`, `out-of-scope` dispositions are allowed."}

Read each of these before proposing any update:
- {workspace_root}/{slug}/context/platform.md (especially the `Established Patterns` section)
- {for each relevant repo:} {repo.path}/AGENTS.md (else legacy {repo.path}/CLAUDE.md) and the agent-context docs it points to
- {for each frontend repo:} {repo.path}/agent-context*/common/DESIGN_SYSTEM.md

## Your job

FIRST, inventory every distinct reviewer comment / discrete feedback item in
the signal and give each a stable id (C-1, C-2, …) — one reviewer remark = one
id; split a comment that bundles N asks into C-3a/C-3b/…. Assign EXACTLY ONE
disposition to every C-n: `doc-finding` (→ a Finding), `code-fix` (→ a CF-n the
implementer must fix — real code defect, not a reusable convention),
`run-local` (→ RL-n), `already-satisfied` (docs + code already comply),
`plugin-level` (→ flagged Finding), or `out-of-scope` (with a one-line reason).
You MUST emit the "Comment coverage" table mapping every C-n to its disposition
and how it was tackled — a comment with no disposition is a defect, not an
allowed omission. This is the completeness guard the user asked for.

THEN, for every meaningful pattern revealed by the signal, produce one finding.
A "meaningful pattern" is a recurring / structural issue — not a one-off
decision that only applied to this particular feature. Err on the side of
NOT proposing updates for one-off decisions. A comment that is a real defect but
not a reusable convention is NOT dropped — it becomes a `code-fix` (CF-n) item.

Per finding, answer:

1. **Observation** — what did the plugin do / what pattern did it use?
2. **Correction** — what's the right pattern (from the review comment / fix
   commit / user text)?
3. **Evidence** — quote the review comment, the commit diff, or the user text
   that establishes this.
4. **Tier** — exactly one of:
   - `run-local` — one-off, no propagation needed. Flag for visibility only.
   - `repo-durable` — convention specific to one repo. Target: that repo's
     CLAUDE.md, agent-context/, or DESIGN_SYSTEM.md.
   - `workspace-durable` — convention shared across all repos (or all repos
     of a given type) in this workspace. Target: platform.md (typically
     `## Established Patterns`).
   - `plugin-level` — universal best practice that would apply to any workspace.
     Target: flagged only, no file edit.
5. **Target file + section** — the exact path + §-section the update would
   touch. If tier is `plugin-level`, write "(plugin maintainer review — no
   workspace file)".
6. **Proposed change** — a before/after diff of the target section. Keep it
   small and surgical. If the target section doesn't exist yet, show it as a
   new section addition.

## Output structure

Feedback analysis — {source identifier}

Recommendation

{update | no-update} — {one sentence. If no-update, this is a complete, successful

answer: say WHY nothing durable should change, e.g. "the session was normal

feature work; no repeatable convention emerged." If update, name how many durable

findings follow.}

Summary

Comment coverage

| Comment | Source | Gist | Disposition | How tackled |

|---|---|---|---|---|

| C-1 | {reviewer @ file:line / sha / "user text"} | {gist} | doc-finding | Finding 1 |

| C-2 | {…} | {…} | code-fix | CF-1 |

{one row per inventoried comment — every C-n appears exactly once}

Coverage check: {total} inventoried, {total} dispositioned → {ALL COMMENTS COVERED | ⚠ UNMAPPED}.

Code-fix items (need an implementer, not a doc update)

{For each CF-n:}

CF-1 — {repo} — {title}

From comment: C-{n}

Repo: {repo-name}

Target: {file}:{line}

What's wrong: {one sentence}

Fix direction: {one sentence}

Evidence: {verbatim quote + source}

{If none: _None._}

Finding 1

Observation

{what did the plugin do}

Correction

{what it should do}

Evidence

{quote + reference}

Tier

{run-local | repo-durable | workspace-durable | plugin-level}

Target

{file path + §-section, or "plugin-level review"}

Proposed change

- {before lines}
+ {after lines}

Finding 2

...


## Ground rules

1. **Quote evidence.** Don't paraphrase reviewer comments or user text — quote
   verbatim.
2. **One finding per distinct pattern.** A single review comment that says
   "use @PreAuthorize AND add tests AND use Specification" is THREE findings.
3. **Prefer workspace over repo scope** when in doubt. A pattern documented at
   the workspace level applies to future repos of the same type too.
4. **If the signal is weak or ambiguous, say so.** Mark low-confidence findings
   with "Confidence: low" and explain why. A finding with weak evidence is
   better rejected than forced. For `session` / free-form `text` sources,
   default to **no durable finding** — these are exploratory, and recommending
   "no change" with a clear reason is a correct, complete answer, not a failure.
   Always emit the top-level `## Recommendation` line stating `update` or
   `no-update`.
5. **No file edits.** You propose, the orchestrator applies after user
   approval. Do NOT use Write or Edit tools.
6. **No plugin-level edits.** For a plugin-level finding, describe the change and
   emit the ISSUE_DRAFT block (see your agent definition). Plugin-relative
   component paths (`agents/x.md`) are allowed inside ISSUE_DRAFT only; `Target`
   stays `(plugin maintainer review — no workspace file)`; never an absolute
   {plugin_dir} path.
7. **Cover every comment.** Every inventoried C-n must appear exactly once in
   the Comment coverage table with a disposition. Dropping a comment because it
   wasn't a "pattern" is the exact failure this guard exists to prevent — route
   it to `code-fix`, `already-satisfied`, or `out-of-scope` instead. End with
   the coverage check line stating ALL COMMENTS COVERED or naming the unmapped
   ids.

The learner is read-only (tools: Read, Glob, Grep, Bash). It does not write anything. Write its raw output to {learn_run_dir}/learner-output.md immediately (re-write after any SendMessage re-dispatch). Pass workspace_slug / workspace_config_path as none in workspace-less mode.


Step 4: Present findings + approval UX

Step 4.0 — coverage gate (run before any per-finding prompt). Parse the learner's ## Comment coverage table and its coverage-check line. Then:

## Comment coverage — {source}   ({covered}/{total} comments dispositioned)

| Comment | Gist | Disposition | How tackled |
|---|---|---|---|
| C-1 | {gist} | doc-finding | Finding 1 |
| C-2 | {gist} | code-fix | CF-1 → fix-round (Step 6.5) |
| C-3 | {gist} | already-satisfied | platform.md §X already says this |
| C-4 | {gist} | out-of-scope | reviewer question, no change |

Code-fix items (CF-n) are carried into the Step 6.5 fix-round bundles (the "ask implementer to fix" path) — flag in the render that they need code changes, not doc edits.

Step 4.1 — per-finding approval. Parse the learner's output into a list of findings. Render each one to the user in a compact format:

## Feedback findings — {source}

Recommendation: {update | no-update} — {the learner's one-sentence justification}
Signal strength: {strong|moderate|weak}
Workspace-durable: {N}   Repo-durable: {N}   Plugin-level (flagged): {N}   Run-local (FYI): {N}

────────────────────────────────────────
[1/N] Finding #1 — {tier} — {target file}

Observation: {one line}
Correction:  {one line}
Evidence:    {one-line quote}
Proposed change: {3-5 line diff preview}

Apply? (y = yes / n = skip / e = edit then apply / v = view full)
────────────────────────────────────────

For each finding:

For plugin-level findings, skip the apply prompt and run the plugin-issue flow below (never a doc edit).

Plugin-issue flow (per plugin-level finding N):

  1. Save the draft. node {plugin_dir}/scripts/extract-block.js {learn_run_dir}/learner-output.md "ISSUE_DRAFT finding-N" --raw → write to {learn_run_dir}/plugin-issues/finding-N.md (omit under --dry-run; show inline instead). Draft missing → ask the learner once via SendMessage; still missing → log Issue: no draft and skip the rest of this flow.
  2. Leak gate. node {plugin_dir}/scripts/check-plugin-issue.js --draft={learn_run_dir}/plugin-issues/finding-N.md --config={config-path} (omit --config workspace-less). Exit 1: SendMessage the learner the hit list — "rewrite finding-N's ISSUE_DRAFT without these terms" — re-extract, re-check once. Still dirty → show the hits and offer only [e] / [s] / [n]. User edit + confirm overrides a hit (record leak-override: <term> in the log); an edit re-runs the check.
  3. Duplicate search. If gh auth status succeeds: gh issue list --repo {plugin_repo} --state open --search "<3–5 title keywords>" --limit 5 --json number,title,url; show matches above the prompt. Any failure → skip silently.
  4. Prompt (full rendered draft, then):
[4/N] Finding #4 — plugin-level — proposed issue for {plugin_repo}
{rendered draft}
{open duplicates, if any}

[f] file now  [s] save draft only  [e] edit  [v] view finding evidence  [n] skip
  1. Print one outcome line per issue (filed #123 <url> | saved <path> | skipped | blocked: leak).

--apply-all / --auto-fix never file: plugin-level drafts are saved and listed in the summary as "saved, not filed". If the user cancels mid-gate, issues already filed stay filed; remaining drafts are saved and the log records the run as partial.

For run-local findings, do not prompt at all — just list them in the summary as informational context and include them in the log.

Batch mode (--apply-all): skip per-finding prompts, show a combined summary + one confirmation. Reject-per-finding is not available in this mode. Plugin-level drafts are saved (leak-checked) and shown as "saved, not filed".

Dry-run mode (--dry-run): show findings + proposed changes (plugin-level drafts inline), emit a single "would apply N findings" summary, skip apply, log write, and draft files. Nothing persists; nothing is filed.

Workspace-less downgrade. When {workspace_mode} = none, any repo-durable / workspace-durable / code-fix finding the learner still returns is downgraded to out-of-scope (reason "no workspace") and never applied.

No actionable findings (common for session / text): if the learner's ## Recommendation is no-update and there are zero repo/workspace/plugin findings, skip the per-finding prompts entirely. Still write the learn-log entry (Step 6) — the reasoning is worth keeping — and go straight to the Step 7 summary, rendering it as the positive "no change recommended" outcome, not a warning. There is nothing to apply and (unless --fix-branch was given) no fix round.


Step 5: Apply approved updates

Skipped in workspace-less mode. For each approved finding:

  1. Read the target file.
  2. Apply the before/after diff. If the target section exists, edit in place. If it's a new section, append at the appropriate position (section number order).
  3. Stamp the file's Last Updated field (if present) to today's date.
  4. Confirm the edit landed — re-read the file, verify the new content is present.
  5. Record in memory: {finding #, target file, status: applied/failed}.

Never use Write to replace a whole doc. Always Edit or surgical append — the user may have hand-curated other sections, and the learner's before block may be slightly stale (recent edits you don't know about). If the Edit's old_string doesn't match (because the file drifted), flag that finding as apply-failed and continue — don't try to force it.

After all applies complete, run a quick sanity check:

Step 6: Write the learn-log entry

Append to {learn_log_path} (create if missing). Format:

## {ISO-date} — {source-mode} {identifier}

**Source**: {mode} ({PR URL / run_id / branch / "text"})
**Source run ID**: {deliver-run-id — ONLY in `run` mode; omit this line for pr / branch / text}
**Signal strength**: {strong|moderate|weak}
**Workspace at time of feedback**: {git rev of workspace config.json, or "n/a"}

### Comment coverage
*(the full audit of how every inventoried reviewer comment was handled — copy the learner's coverage table)*

| Comment | Gist | Disposition | How tackled |
|---|---|---|---|
| C-1 | {gist} | doc-finding | Finding 1 (applied) |
| C-2 | {gist} | code-fix | CF-1 → fix-round: applied |
| C-3 | {gist} | already-satisfied | platform.md §X |
| C-4 | {gist} | out-of-scope | reviewer question |

**Coverage**: {covered}/{total} comments dispositioned — {ALL COVERED | ⚠ list unmapped}.

### Code-fix items
*(reviewer-flagged defects that became implementer work, not doc updates — appears only if the learner produced CF-n items)*

| CF | From | Repo | Target | Disposition |
|---|---|---|---|---|
| CF-1 | C-2 | abvi-backoffice-service | ContentRatingTaskService.java:142 | fixed in round (or: deferred / fix-skipped) |

### Findings applied
| # | Tier | Target | Summary |
|---|---|---|---|
| 1 | workspace-durable | platform.md § Established Patterns | Auth pattern documented as SecurityConfig + @PreAuthorize |
| 2 | workspace-durable | platform.md § Established Patterns | Query pattern documented as Specification<> |
| 3 | repo-durable | abvi-backoffice-service/CLAUDE.md | Added note: service exposes contract endpoints since PR #31 |

### Findings rejected
| # | Tier | Target | Reason |
|---|---|---|---|
| 4 | workspace-durable | platform.md | User rejected: "this is a one-off" |

### Findings flagged (plugin-level)
| # | Summary | Issue |
|---|---|---|
| 5 | Plugin-level: spring-boot implementer should prefer declarative security on greenfield code | #123 <url> |

`Issue` = `#123 <url>` | `draft: <path>` | `skipped` | `blocked: leak` | `no draft`. Add `leak-override: <term>` and `legacy path` notes where they apply.

### Fix-round dispatches
*(this subsection appears only if Step 6.5 ran and at least one bundle was dispatched)*

| Repo | Branch | Implementer | Duration | Tokens | Applied | Skipped | Tests | Lint |
|---|---|---|---|---|---|---|---|---|
| abvi-pms-frontend | feature/contract-view-and-list | react-implementer | 4m 12s | 38K | #1, #3, #4, #5 | #2 (covered by #1) | pass | pass |
| abvi-publisher-service | feature/contract-view-and-list | spring-boot-implementer | 2m 04s | 19K | — | (no bundle — no findings for this repo) | — | — |

For each row that has a `Notes for the user` line in the agent output, also include it as a bullet underneath the table.

### Notes
- Invocation args: `--pr=... --note="..." [--fix-branch=... | --auto-fix | --no-fix]`
- Duration: {mm:ss} (orchestrator + learner + fix-round dispatches combined)
- Learner tokens used: ~{N}k
- Fix-round tokens used: ~{N}k *(only if Step 6.5 dispatched anything)*

The log is the durable record of how the workspace learned over time. Future /pipecrew:learn invocations can cross-reference this log to spot recurring patterns.

Each plugin-level finding's outcome line is printed during the Step 4 plugin-issue flow; the log table above carries the same outcome.

Step 6.5: Optional fix round — apply findings to existing code

Doc updates from Step 5 only steer future runs. The branch the feedback came from still contains the violations the user flagged. This step optionally dispatches the per-repo implementer agents to fix them in place.

Skip this step entirely when ANY of the following holds:

Code-fix items are first-class fix-round input. The fix round addresses two kinds of work: (a) approved doc findings whose convention the branch still violates, and (b) the learner's code-fix (CF-n) items — real defects a reviewer flagged that aren't reusable conventions. Both flow through the same per-repo bundling below. CF-n items make the round worth running even when every doc finding was rejected.

Otherwise:

6.5.1 — Group approved findings AND code-fix items by affected repo

For each applied (non-plugin-level) finding, resolve the affected repo:

  1. The finding's target file path always lives under one of config.repos[*].path — match by longest-prefix path. For each finding store {finding_id, repo_name, repo_type, repo_path, target_doc_path}.
  2. The Observation / Evidence sections also contain concrete source-file references (e.g., src/components/contracts/DownloadContractButton.tsx). Extract any path that resolves under the same repo_path — these become the per-finding affected_files list.
  3. If a finding has no in-repo source files (it's purely about adding a new file or moving things around), keep the finding but mark affected_files: [] — the implementer will use the Correction text to decide what to create / move.

Then add the learner's code-fix (CF-n) items. Each CF-n already names its repo and target file:line. Resolve its repo_path the same way and fold it into that repo's bundle as a fix-list entry of kind code-fix (alongside any doc findings). A CF-n carries no doc to update — its "reference convention" is the reviewer comment itself; pass its What's wrong + Fix direction + evidence straight through. A repo that has only CF-n items and no doc findings still gets a bundle.

If the same repo is targeted by multiple findings and/or CF-n items, group them into ONE per-repo bundle. The orchestrator will dispatch ONE implementer per bundle, not N.

6.5.2 — Resolve the implementer agent per repo

Use the canonical TYPE_TO_AGENT mapping in {plugin_dir}/skills/deliver/phases/dispatch-rules.md § "Agent Dispatch (TYPE_TO_AGENT mapping)". Same fallback chain applies:

  1. Workspace-local override at {slug}-{type}-implementer.md in the harness user-level agents dir (~/.claude/agents/ under Claude Code, ~/.cursor/agents/ under Cursor) — prefer if present.
  2. Plugin-shipped implementer from the table.
  3. general-purpose with the standard preamble — last resort.

If the type has no plugin agent AND no workspace-local override (e.g., type: api-collections), skip that repo's bundle and tell the user — there is no implementer to dispatch.

6.5.3 — Resolve the target branch per repo

In priority order:

  1. If --fix-branch=<name> was passed, use that name across every affected repo.
  2. Otherwise, run git -C {repo_path} branch --show-current for each repo and use whatever is currently checked out.
  3. If a repo is in a detached-HEAD state, or the resolved branch is main / master / dev (the workspace's protected base — read from repos[*].main_branch if present, else default heuristic), do NOT auto-proceed — explicitly ask the user to name a branch. The fix round must never run against a protected branch by default.

Verify the branch exists on disk: git -C {repo_path} rev-parse --verify {branch}. If it doesn't, warn and skip that repo.

Do NOT create a worktree. Unlike /deliver, the fix round operates on the user's existing branch in-place — that branch is the whole point. The implementer agents are documented to work in their repo_path argument; pass the actual repo path, not a worktree path.

6.5.4 — Per-repo confirmation gate

For each repo bundle, before dispatching, render:

## Fix-round dispatch — {repo_name}

Implementer:  {resolved_subagent_type}
Branch:       {resolved_branch}    (resolved via {flag | current | user-input})
Findings:     {N} ({list of finding IDs and one-line summaries})
Code-fixes:   {M} ({list of CF IDs and one-line summaries — reviewer-flagged defects})
Files in scope: {list of resolved affected_files + CF target files, or "(implementer will derive from Correction text)"}

Dispatch? (y = yes / n = skip this repo / b = pick a different branch)

--auto-fix skips this prompt and answers y for every bundle, BUT the protected-branch check from 6.5.3 still applies — --auto-fix will not silently dispatch against main/master/dev; in that case it pauses and asks for a branch.

6.5.5 — Build the implementer prompt

For each queued bundle, dispatch via Agent tool with the resolved subagent_type. The prompt is structured the same way every implementer accepts a fix_list-style input. Pass:

**Tool**: Agent
**subagent_type**: {resolved_subagent_type}
**description**: "Fix round on {repo_name} — {N} findings from /learn"

**Prompt body** (literal — substitute placeholders):

You are dispatched as a fix-round implementer following a /pipecrew:learn run on the
{workspace.name} workspace. The user just approved {M} workspace/repo durable doc updates
that codify conventions this branch violated. Your job is to bring the existing branch in
line with those new conventions.

repo_path: {repo_path}
branch:    {resolved_branch}    (already checked out — do NOT create a worktree, do NOT switch
                                 branches, do NOT push, do NOT create commits unless explicitly
                                 asked by the user later)

Convention docs that were just updated (read these first — they are the source of truth):
{for each doc edited at Step 5 that lives under this repo:}
- {repo-relative path}    — section: "{section header that was added/edited}"

Findings to apply (fix_list):

{for each finding in this bundle:}
### Finding {id} — {one-line summary}
- **Observation** (what the code currently does): {finding.Observation}
- **Correction** (what the code must do): {finding.Correction}
- **Affected files** (resolved from Evidence — refine if you find more):
  {bullet list of finding.affected_files; or "(none yet — derive from Correction)"}
- **Reference convention**: {repo-relative path of the doc updated at Step 5 for this finding},
  section "{section name}". Re-read it before editing — that is the rule of record.

Code-fix items (fix_list — reviewer-flagged defects, no doc to read; the comment IS the spec):

{for each CF-n in this bundle:}
### {CF-id} — {one-line summary}  (from review comment {C-n})
- **What's wrong** (current behavior): {cf.whats_wrong}
- **Fix direction** (what the code must do): {cf.fix_direction}
- **Target files**: {cf.target file:line list}
- **Reviewer evidence**: {cf.evidence verbatim quote + source}. This is the rule of record for this item — there is no durable doc; apply exactly what the reviewer asked.

Constraints:
1. Edit ONLY the named files plus any of their direct callers / imports / tests that break
   because of the edit. Do NOT range further.
2. Update tests that exercise the changed code paths. If a test encodes the OLD behavior as
   the expected behavior, update both the test name and the assertion to match the new
   convention.
3. After all edits, run the repo's test suite and lint (use the commands documented in
   {repo_path}/AGENTS.md, else legacy {repo_path}/CLAUDE.md). Report failures — do not gloss over them.
4. Do NOT commit. Do NOT push. Leave the working tree dirty for the user to inspect.
5. If a finding cannot be applied (e.g., the file was deleted on this branch, or the
   correction conflicts with another finding in this bundle), mark it
   `fix-skipped: {reason}` in your output and continue with the others.

Output (use this structure verbatim):

## Fix round outcome — {repo_name}
- Findings applied: {list ids}
- Findings skipped: {list ids with reason}
- Files changed: {list with one-line summary per file}
- Tests run: {command} → {pass | fail count}
- Lint: {command} → {pass | fail count}
- Notes for the user: {any judgement calls you made or anything they should review by hand}
6.5.6 — Run dispatches in parallel across repos, sequential within a repo

Dispatch all per-repo bundles in parallel by issuing multiple Agent tool calls in a single message — the same parallelism rule /deliver uses for cross-repo work. Multiple findings within the same repo always go in ONE bundle to one implementer; never split same-repo findings across two parallel agents (they would race on the same files).

6.5.7 — Capture per-bundle outcome

Parse each agent's <usage> block for duration_ms and total_tokens. Capture the ## Fix round outcome block from the agent's response verbatim. For each bundle store {repo_name, branch, subagent_type, duration_ms, total_tokens, applied_finding_ids, skipped_finding_ids, files_changed, test_status, lint_status, notes}.

These records feed the Step 6 log entry's new "Fix-round dispatches" subsection (write the log AFTER 6.5 if any fix-round dispatches ran — see Step 6 note below) and the Step 7 summary line.

Re-write of the learn-log entry. Step 6 may have already written the entry before 6.5 ran. If 6.5 produced any fix-round outcomes, append a ### Fix-round dispatches subsection to the same entry (don't write a second entry). This keeps one log row per /learn invocation.

Step 7: Summary

Emit the standard one-line phase-done status. Include a fix-round suffix when Step 6.5 dispatched at least one bundle:

[feedback ✔] {N} applied, {N} rejected, {N} plugin-flagged — {source} ({mm:ss}, {Xk} tokens)
            ↳ coverage: {covered}/{total} comments dispositioned ({C} code-fix items)
            ↳ fix-round: {R} repos, {A} findings + {CF} code-fixes applied to code, {S} skipped
            ↳ plugin issues: {F} filed, {S} saved, {K} skipped

Always print the coverage line — it is the at-a-glance proof that no reviewer comment was silently dropped. If coverage is < 100%, use ⚠ and name the unmapped ids.

No durable change — distinguish deliberate from incomplete. When 0 findings were applied:

[feedback ✔] no context change recommended — session "modal-vs-route" (1:48, 12k tokens)
  Looked at 9 turns; all run-local (normal feature work). Reasoning recorded in learn-log.md.
  ↳ coverage: 9/9 turns dispositioned
[feedback ✔⚠] 0 applied, 4 rejected, 1 plugin-flagged — PR #31 (2:15, 18k tokens)
  No workspace docs updated. Rejections recorded in learn-log.md.

If the doc applies succeeded but the fix-round prompt was declined / --no-fix was passed, mention that explicitly so the user remembers the existing branch was NOT touched:

[feedback ✔] 4 applied, 0 rejected, 0 plugin-flagged — text "contract-view-and-list" (3:22, 22k tokens)
  Fix round: skipped (--no-fix). Existing branches still violate the new conventions.

Step 7.4: Sync workspace memory to GitHub (skipped workspace-less; only if `config.workspace.memory.enabled` AND ≥1 finding applied)

If the workspace opted into GitHub-backed memory and this run changed any durable doc (≥1 finding applied to platform.md / repo CLAUDE.md / agent-context / DESIGN_SYSTEM.md / audit-findings.md), persist it:

node {plugin_dir}/scripts/sync-memory.js {workspace_root}/{slug} --message "learn: {N} updates — {source}" --checkpoint=learn

Skip when memory.enabled is absent/false, or when 0 findings were applied (nothing to sync). The script redacts secrets, commits the durable docs, rebases onto the team's latest, and publishes per config.workspace.memory.sync_mode — commit pushes straight to main; hybrid/pr open a memory/* PR when the change touches platform.md / an ADR (a rebase conflict always routes through a PR). Push/PR failures warn but never fail /learn. Note: workspace-level findings update {workspace_root}/{slug}/context/* (synced here); repo-level findings update files inside the code repos (committed in those repos' own git, not here).

Step 7.5: Finalize — update parent /deliver dispatch log (only when `--run` was supplied)

This is the only /deliver-specific step. If /learn was invoked with --run=<deliver-run-id> (for example dispatched from /deliver Phase 8 Step 8.6), the parent /deliver run's scratchpad.md already has a feedback-learner row in its ## Agent Dispatch Log table with outcome in_progress (written by Phase 8 just before the Skill invocation). Update it now so the site-view's loop character flips working → done and the pyramid closes.

Locate the row: {workspace_root}/{slug}/runs/deliver/{deliver-run-id}/scratchpad.md. Find the row whose Agent column is feedback-learner and Outcome is in_progress.

Update the row in place. Preserve the #, Phase, and Agent columns. Set:

Use a single Edit (not Write) — append-only is wrong here, the row is being mutated. The file must keep its existing structure; only this row changes.

If the row is not found (e.g. /learn was invoked manually with --run outside the Phase 8 path, so /deliver never wrote the placeholder), skip the row update silently. Do not synthesize a row in that case — the user is running /learn ad-hoc and the /deliver run is already finalized.

Record the reverse link (learn_runs.json). The forward link (this learn run → its source deliver run) is the learn-log entry's **Source run ID** line. To make the reverse link queryable — a deliver run → the learn runs that analyzed it — write/merge {workspace_root}/{slug}/runs/deliver/{deliver-run-id}/learn_runs.json (the same machine-readable sidecar pattern Phase 8 uses for pr_urls.json):

{
  "analyzed_by": [
    { "learn_run_id": "{this learn run_id}", "ts": "{ISO-8601}", "findings_applied": {A}, "findings_rejected": {R}, "findings_flagged": {F} }
  ]
}

Read-and-merge if the file already exists (a deliver run can be analyzed more than once) — append one analyzed_by[] entry, never overwrite prior ones. Do this even when the dispatch-log row above was absent (the ad-hoc --run case still benefits from the back-reference). Downstream tooling then has a direct "which learn runs touched this deliver run, and what did they change?" lookup without scanning every workspace's history/learn-log.md.

If --run was not supplied (PR / branch / free-form modes), this entire step is a no-op.


INTERRUPTION HANDLING


Observability

Every /pipecrew:learn run emits the same event schema as /deliver / /discover runs (see {plugin_dir}/rules/observability.md):

Run directory: {learn_run_dir} (defined in Step 1.6).

Keep the learner's raw output under {learn_run_dir}/learner-output.md for post-hoc debugging. The log entry is the human-facing summary; the raw output is the full reasoning trail.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.