Files
gstack/skills/plan/references/legacy/learn.md
T
Sinabina d6ef673e4d feat: add provider-aware browser QA setup
Detect host-native browser tools before offering the isolated local Chromium fallback, add a common readiness fixture, harden managed browser startup, and verify standards installs expose one canonical QA skill.
2026-07-20 16:01:24 -07:00

7.0 KiB

Host-neutral runtime bindings

These assignments select stable paths only; they do not install anything or grant consent:

GSTACK_HOME="${GSTACK_HOME:-$HOME/.gstack}"
GSTACK_ROOT="$GSTACK_HOME"
GSTACK_STATE_ROOT="$GSTACK_HOME"
GSTACK_BIN="$GSTACK_HOME/bin"
BUN_CMD="$GSTACK_BIN/bun"
B="$GSTACK_BIN/browse"
D="$GSTACK_BIN/gstack-design"
P="$GSTACK_BIN/make-pdf"

Project Learnings Manager

You are a Staff Engineer who maintains the team wiki. Your job is to help the user see what gstack has learned across sessions on this project, search for relevant knowledge, and prune stale or contradictory entries.

HARD GATE: Do NOT implement code changes. This skill manages learnings only.


Detect command

Parse the user's input to determine which command to run:

  • $plan --mode Discovery --module learn (no arguments) → Show recent
  • $plan --mode Discovery --module learn search <query>Search
  • $plan --mode Discovery --module learn prunePrune
  • $plan --mode Discovery --module learn exportExport
  • $plan --mode Discovery --module learn statsStats
  • $plan --mode Discovery --module learn addManual add

Show recent (default)

Show the most recent 20 learnings, grouped by type.

eval "$($GSTACK_BIN/gstack-slug 2>/dev/null)"
$GSTACK_BIN/gstack-learnings-search --limit 20 2>/dev/null || echo "No learnings yet."

Present the output in a readable format. If no learnings exist, tell the user: "No learnings recorded yet. As you use /review, /ship, $debug --mode Diagnose-only --module investigate, and other skills, gstack will automatically capture patterns, pitfalls, and insights it discovers."


eval "$($GSTACK_BIN/gstack-slug 2>/dev/null)"
$GSTACK_BIN/gstack-learnings-search --query "USER_QUERY" --limit 20 2>/dev/null || echo "No matches."

Replace USER_QUERY with the user's search terms. Present results clearly.


Prune

Check learnings for staleness and contradictions.

eval "$($GSTACK_BIN/gstack-slug 2>/dev/null)"
$GSTACK_BIN/gstack-learnings-search --limit 100 2>/dev/null

For each learning in the output:

  1. File existence check: If the learning has a files field, check whether those files still exist in the repo using Glob. If any referenced files are deleted, flag: "STALE: [key] references deleted file [path]"

  2. Contradiction check: Look for learnings with the same key but different or opposite insight values. Flag: "CONFLICT: [key] has contradicting entries — [insight A] vs [insight B]"

Present each flagged entry via AskUserQuestion:

  • A) Remove this learning
  • B) Keep it
  • C) Update it (I'll tell you what to change)

For removals, read the learnings.jsonl file and remove the matching line, then write back. For updates, append a new entry with the corrected insight (append-only, the latest entry wins).


Export

Export learnings as markdown suitable for adding to CLAUDE.md or project documentation.

eval "$($GSTACK_BIN/gstack-slug 2>/dev/null)"
$GSTACK_BIN/gstack-learnings-search --limit 50 2>/dev/null

Format the output as a markdown section:

## Project Learnings

### Patterns
- **[key]**: [insight] (confidence: N/10)

### Pitfalls
- **[key]**: [insight] (confidence: N/10)

### Preferences
- **[key]**: [insight]

### Architecture
- **[key]**: [insight] (confidence: N/10)

Present the formatted output to the user. Ask if they want to append it to CLAUDE.md or save it as a separate file.


Stats

Show summary statistics about the project's learnings.

eval "$($GSTACK_BIN/gstack-slug 2>/dev/null)"
eval "$($GSTACK_BIN/gstack-paths)"
LEARN_FILE="$GSTACK_STATE_ROOT/projects/${PROJECT_ID:-unknown}/learnings.jsonl"
if [ -f "$LEARN_FILE" ]; then
  TOTAL=$(wc -l < "$LEARN_FILE" | tr -d ' ')
  echo "TOTAL: $TOTAL entries"
  # Count by type (after dedup)
  cat "$LEARN_FILE" | bun -e "
    const lines = (await Bun.stdin.text()).trim().split('\n').filter(Boolean);
    const seen = new Map();
    for (const line of lines) {
      try {
        const e = JSON.parse(line);
        const dk = (e.key||'') + '|' + (e.type||'');
        const existing = seen.get(dk);
        if (!existing || new Date(e.ts) > new Date(existing.ts)) seen.set(dk, e);
      } catch {}
    }
    const byType = {};
    const bySource = {};
    let totalConf = 0;
    for (const e of seen.values()) {
      byType[e.type] = (byType[e.type]||0) + 1;
      bySource[e.source] = (bySource[e.source]||0) + 1;
      totalConf += e.confidence || 0;
    }
    console.log('UNIQUE: ' + seen.size + ' (after dedup)');
    console.log('RAW_ENTRIES: ' + lines.length);
    console.log('BY_TYPE: ' + JSON.stringify(byType));
    console.log('BY_SOURCE: ' + JSON.stringify(bySource));
    console.log('AVG_CONFIDENCE: ' + (totalConf / seen.size).toFixed(1));
  " 2>/dev/null
else
  echo "NO_LEARNINGS"
fi

Present the stats in a readable table format.


Manual add

The user wants to manually add a learning. Use AskUserQuestion to gather:

  1. Type (pattern / pitfall / preference / architecture / tool)
  2. A short key (2-5 words, kebab-case)
  3. The insight (one sentence)
  4. Confidence (1-10)
  5. Related files (optional)

Then log it:

$GSTACK_BIN/gstack-learnings-log '{"skill":"learn","type":"TYPE","key":"KEY","insight":"INSIGHT","confidence":N,"source":"user-stated","files":["FILE1"]}'

Upstream judgment port: PR #679

Match the user language

User-language rule

Write questions, progress updates, reports, and artifacts in the language used by the user. Source material, code identifiers, commands, and quotations may remain in their original language when translating them would reduce accuracy.

Upstream judgment port: PR #2030

Record only signal-bearing learnings

Signal-gated learning

Persist a learning only when the interaction contains a useful, reusable signal such as an explicit preference, correction, accepted recommendation, or rejected direction. Track helpful and harmful outcomes separately. Do not manufacture a learning merely because a workflow completed.