learn

learn is a command for Claude Code from synaptiai/synapti-marketplace. It costs 35 tokens per session (14,262 once invoked), scanned A, original, Apache-2.0.

A command that studies the project's decision journal, a record of past choices, to find repeated patterns and suggest reusable skills.

In plain words
What is it for?
Use it for retrospective analysis of project decisions and for proposing new skills based on repeated practices.
Why use it?
It helps convert recurring corrections and working patterns into guidance that can be reused in future tasks.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: reads .claude/ paths; mentions Claude Code.

Runs only inside its plugin — its command needs a path that Claude Code sets for a plugin’s own hooks and for nothing else. Install the plugin, not this.

Part of the flow plugin — 33 skills, 20 commands, 11 agents shipped together

Good fit Use it for retrospective analysis of project decisions and for proposing new skills based on repeated practices.

Compare 6 commands from other repositories ↓
Install

Getting it into your agent

This one installs as part of its plugin. Adding the marketplace and installing the plugin brings it with everything else the plugin ships.

Claude Code
/plugin marketplace add synaptiai/synapti-marketplace
Claude Code
/plugin install flow

Made for: Claude Code.

Or install flow, the plugin that ships this one along with the rest of its 33 skills, 20 commands, 11 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for learn

README.md
[![agentmods](https://agentmods.dev/badge/commands/synaptiai/synapti-marketplace/learn/github.svg)](https://agentmods.dev/commands/synaptiai/synapti-marketplace/learn)
Your own site
<a href="https://agentmods.dev/commands/synaptiai/synapti-marketplace/learn"><img src="https://agentmods.dev/badge/commands/synaptiai/synapti-marketplace/learn/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for learn

Your own site · 80×15
<a href="https://agentmods.dev/commands/synaptiai/synapti-marketplace/learn"><img src="https://agentmods.dev/badge/commands/synaptiai/synapti-marketplace/learn.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 35 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 14,262 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00035 $0.14262
Opus 5.5 $0.00014 $0.05705
Sonnet 5.5 $0.00007 $0.02852
Haiku 4.5 $0.00003 $0.01426

Measured 25d ago against content hash d745c9912235, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

learn scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 25d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/flow/commands/learn.md · 739 lines

How it starts

The opening of the file, as written. The whole thing — 739 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Learn from Decisions

Analyze the decision journal and the session transcripts for recurring patterns and generate skill proposals.

The journal and run ledgers only contain what flow wrote about itself. The corrections a user actually made ("that's not what I asked", "I opened it and it is empty", "why didn't you run the tests?") live in the Claude Code session transcripts, so Phase 1 mines those too.

Required Skills

None — retrospective pattern analysis over the decision journal and transcripts. No skill invocations.

Phase 1: Gather Journal Entries

# Keep the repository out of PYTHONPATH before python3 starts: the interpreter
# imports sitecustomize from each element at startup. An isolated python3 (-I:
# it reads neither PYTHONPATH nor the working directory) keeps only elements
# that are directories outside the repository and not at or above the working
# directory, comparing directories by identity, not by how the path is spelled;
# tests/syspath-guard.test.sh has the reasons. FLOW_USER_PYTHONPATH keeps the
# original for commands run for the user.
[ -n "${FLOW_USER_PYTHONPATH+x}" ] || export FLOW_USER_PYTHONPATH="${PYTHONPATH-}" FLOW_USER_PYTHONPATH_SET="${PYTHONPATH+1}" FLOW_USER_PYTHONSAFEPATH="${PYTHONSAFEPATH-}" FLOW_USER_PYTHONSAFEPATH_SET="${PYTHONSAFEPATH+1}"
_flow_pp=""; if [ -n "${PYTHONPATH-}" ]; then _flow_pp=$(python3 -I -c 'exec("import os, sys\ndef ids(p):\n    out = set()\n    while True:\n        try:\n            st = os.stat(p)\n        except OSError:\n            return out\n        out.add((st.st_dev, st.st_ino))\n        q = os.path.dirname(p)\n        if q == p:\n            return out\n        p = q\ntry:\n    cwd = os.getcwd()\nexcept OSError:\n    sys.exit(0)\ntop = d = cwd\nwhile True:\n    if os.path.lexists(os.path.join(d, \".git\")):\n        top = d\n        break\n    q = os.path.dirname(d)\n    if q == d:\n        break\n    d = q\nst = os.stat(top)\ntop_id = (st.st_dev, st.st_ino)\nup = ids(cwd)\nkeep = []\nfor e in os.environ.get(\"PYTHONPATH\", \"\").split(\":\"):\n    if not e.startswith(\"/\"):\n        continue\n    r = os.path.realpath(e)\n    if \":\" in r or chr(10) in r or not os.path.isdir(r):\n        continue\n    try:\n        st = os.stat(r)\n    except OSError:\n        continue\n    if (st.st_dev, st.st_ino) in up or top_id in ids(r):\n        continue\n    keep.append(r)\nsys.stdout.buffer.write(os.fsencode(\":\".join(keep)))")' 2>/dev/null) || _flow_pp=""; fi
if [ -n "$_flow_pp" ]; then export PYTHONPATH="$_flow_pp"; else unset PYTHONPATH; fi
# Output: `###`-headed sections + KEY=value per
# `references/command-output-format.md`.

printf '%s\n' "### Resolved Paths"
# JOURNAL_DIR resolves through bin/journal-dir.sh, as every journal writer
# resolves it; PROPOSAL_DIR via the standard settings cascade.
# settings.json may store paths with a leading `~` (literal — JSON has no
# tilde-expansion semantics). The cascade helper returns the value verbatim
# without expansion, so downstream tools that do not auto-expand tildes
# (Read/Write/Edit, Python os.path) would fail. Manually expand `~` to
# the home of the user so the agent always receives an absolute path. The home is
# the one cascade-resolve.sh --user-home gives: a HOME the repository sets
# does not choose where proposals go.
HELPER="$(__fr="${CLAUDE_PLUGIN_ROOT:-}";[ -x "$__fr/bin/cascade-resolve.sh" ]||__fr=$({ printf '%s\n' plugins/flow;ls -d "${CLAUDE_CONFIG_DIR:-$HOME/.claude}"/plugins/cache/synapti-marketplace/flow/*/ 2>/dev/null|sort -Vr;printf '%s\n' "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/plugins/marketplaces/synapti-marketplace/plugins/flow"; }|while read -r __p;do [ -x "${__p%/}/bin/cascade-resolve.sh" ]&&{ printf '%s\n' "${__p%/}";break;};done);printf '%s\n' "$__fr")/bin/cascade-resolve.sh"
JOURNAL_DIR=".decisions"
USER_HOME=""
# The home comes from a resolver outside the repository (the lookup skips any
# copy inside it): a copy the repository ships must not say where it is.
# USER_FILES_BEGIN
USER_HELPER="$(__t=$(git rev-parse --show-toplevel 2>/dev/null);__x=0;[ -z "$__t" ]||{ __t=$(cd "$__t" 2>/dev/null&&pwd -P);[ -n "$__t" ]||__x=1; };[ "$__x" = 1 ]||{ printf '%s\n' "${CLAUDE_PLUGIN_ROOT:-}";ls -d "${CLAUDE_CONFIG_DIR:-$HOME/.claude}"/plugins/cache/synapti-marketplace/flow/*/ 2>/dev/null|sort -Vr;printf '%s\n' "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/plugins/marketplaces/synapti-marketplace/plugins/flow"; }|while read -r __p;do __p=${__p%/};[ -n "$__p" ]&&[ -x "$__p/bin/cascade-resolve.sh" ]||continue;__r=$(cd "$__p" 2>/dev/null&&pwd -P)||continue;[ -n "$__r" ]||continue;[ -z "$__t" ]||{ __d=$__r;__in=0;while :;do [ "$__d" -ef "$__t" ]&&{ __in=1;break; };[ "$__d" = / ]&&break;__d=$(dirname "$__d");done;[ "$__in" = 1 ]&&continue; };printf '%s\n' "$__r";break;done)/bin/cascade-resolve.sh"
# USER_FILES_END
[ -x "$USER_HELPER" ] && USER_HOME=$("$USER_HELPER" --user-home 2>/dev/null)
case "$USER_HOME" in /*) ;; *) USER_HOME=/nonexistent ;; esac
PROPOSAL_DIR="$USER_HOME/.claude/flow-proposals"
if [ -x "$HELPER" ]; then
  # Both values are printed below as `KEY=value` lines, and
  # .claude/settings.flow.json is a tracked file, so a fork pull request chooses
  # them. cascade-resolve.sh refuses a value carrying a newline by default —
  # without that, one in journal.dir closed the JOURNAL_DIR= line and opened a
  # forged `### Dismissal Artifacts` section above the real one.
  JOURNAL_DIR=$("${HELPER%/cascade-resolve.sh}/journal-dir.sh")
  [ -n "$JOURNAL_DIR" ] || JOURNAL_DIR=".decisions"
  # Proposals are written where this names, so only the user settings file
  # and the plugin default may name it: a repository setting could aim them
  # at any directory the user can write. USER_HELPER, defined above, skips
  # any copy of the resolver inside the repository, as the review command
  # finds its own: a copy the repository ships must not answer this.
  if [ -x "$USER_HELPER" ] && __pd=$("$USER_HELPER" --no-repo-settings --default "$USER_HOME/.claude/flow-proposals" '.learning.proposalDir // empty'); then
    PROPOSAL_DIR=$__pd
  else
    printf '%s\n' "WARN=learning.proposalDir could not be read from the user settings (no installed flow outside this repository answered); using the default"
  fi
  printf '%s\n' "STATE=ok"
else
  # Helper missing or non-executable — using compile-time defaults. Surface
  # so the agent knows resolution was best-effort and config might be ignored.
  printf '%s\n' "STATE=unavailable"
  printf '%s\n' "ERROR=cascade-resolve.sh missing or non-executable; using built-in defaults"
fi
# Expand leading `~` to the home of the user so downstream Read/Write/Edit tools
# (which do not tilde-expand) receive absolute paths.
JOURNAL_DIR="${JOURNAL_DIR/#\~/$USER_HOME}"
PROPOSAL_DIR="${PROPOSAL_DIR/#\~/$USER_HOME}"
# A relative value would resolve inside the working directory, the repository.
case "$PROPOSAL_DIR" in
  /*) ;;
  *) printf '%s\n' "WARN=learning.proposalDir is not an absolute path or one under ~; using the default"
     PROPOSAL_DIR="$USER_HOME/.claude/flow-proposals" ;;
esac
printf '%s\n' "JOURNAL_DIR=$JOURNAL_DIR"
printf '%s\n' "PROPOSAL_DIR=$PROPOSAL_DIR"

printf '%s\n' ""
printf '%s\n' "### Journal Files"
JOURNAL_FILES=0
[ -d "$JOURNAL_DIR" ] && JOURNAL_FILES=$(ls "$JOURNAL_DIR"/*.md 2>/dev/null | wc -l | tr -d ' ')
printf '%s\n' "JOURNAL_FILE_COUNT=$JOURNAL_FILES"
if [ "$JOURNAL_FILES" = "0" ]; then
  printf '%s\n' "STATE=empty"
else
  ls "$JOURNAL_DIR"/*.md 2>/dev/null | sed 's/^/JOURNAL_FILE=/'
fi

printf '%s\n' ""
printf '%s\n' "### Proposal Files"
PROPOSAL_FILES=0
[ -d "$PROPOSAL_DIR" ] && PROPOSAL_FILES=$(ls "$PROPOSAL_DIR"/*.md 2>/dev/null | wc -l | tr -d ' ')
printf '%s\n' "PROPOSAL_FILE_COUNT=$PROPOSAL_FILES"
if [ "$PROPOSAL_FILES" = "0" ]; then
  printf '%s\n' "STATE=empty"
else
  ls "$PROPOSAL_DIR"/*.md 2>/dev/null | sed 's/^/PROPOSAL_FILE=/'
fi

# Section: FlowRun Events + FlowGoals (v3)
# Gated behind flow.goals.enabled — when v3 is enabled, surface the goal
# YAMLs + run-event ledgers so the Phase 2 Goal Failure Patterns can detect
# recurring failed ACs, stuck-detection hits, and ACs never verified.
printf '%s\n' ""
printf '%s\n' "### FlowRun Events"
GOALS_ENABLED="false"
[ -x "$HELPER" ] && GOALS_ENABLED=$("$HELPER" --default "true" '.flow.goals.enabled' 2>/dev/null)
if [ "$GOALS_ENABLED" != "true" ]; then
  printf '%s\n' "STATE=disabled"
else
  # Goals and runs are under the runtime directory, flow.runtime.stateDir
  # (default .flow), printed as RUNTIME_DIR. No goal is read through a
  # symlink. A repository can commit that directory or its goals, or a goal
  # file, as a symlink to something outside the checkout, and a goal read
  # there belongs to the target of the link.
  # flow-mkdir.sh --check is the rule every flow writer applies below the
  # repository; a refusal is said on stderr and no goal file is listed. A
  # check that cannot run (exit 3: python3 missing) is not a refusal and not
  # an empty directory: the section is then unavailable.
  GOAL_FILES=0
  GOAL_LIST=""
  LEARN_UNCHECKED=""
  RT=$("${HELPER%/cascade-resolve.sh}/flow-runtime-dir.sh") || RT=""
  [ -n "$RT" ] || RT=".flow"
  printf '%s\n' "RUNTIME_DIR=$RT"
  # The goals are at the repository top, wherever below the top this block
  # runs: flow-runtime-dir.sh --goals prints the directory flow-goal-record.sh
  # writes and flow-active-goal.sh reads.
  GOALS_DIR=$("${HELPER%/cascade-resolve.sh}/flow-runtime-dir.sh" --goals) || GOALS_DIR=""
  [ -n "$GOALS_DIR" ] || GOALS_DIR="$RT/goals"
  GOAL_DIR_RC=0
  GOAL_DIR_ERR=$("${HELPER%/cascade-resolve.sh}/flow-mkdir.sh" --check -- "$GOALS_DIR" 2>&1) || GOAL_DIR_RC=$?
  GOAL_DIR_ERR=${GOAL_DIR_ERR#flow-mkdir.sh: }
  # A Windows python3 ends the line in \r\n, which $(...) keeps the \r of.
  GOAL_DIR_ERR=${GOAL_DIR_ERR%$'\r'}
  if [ "$GOAL_DIR_RC" -eq 0 ]; then
    if [ -d "$GOALS_DIR" ]; then
      GOAL_LIST=$(find "$GOALS_DIR" -maxdepth 1 -name '*.goal.yaml' ! -type l 2>/dev/null | LC_ALL=C sort)
      find "$GOALS_DIR" -maxdepth 1 -name '*.goal.yaml' -type l 2>/dev/null | LC_ALL=C sort |
        while IFS= read -r GOAL_LINK; do
          printf 'refusing — %s is a symlink; goals are not read through it\n' "$GOAL_LINK" >&2
        done
    fi
  elif [ "$GOAL_DIR_RC" -eq 2 ]; then
    printf '%s; goals are not read through it\n' "${GOAL_DIR_ERR%"; nothing is written under it"}" >&2
  else
    LEARN_UNCHECKED=$(printf '%s' "$GOAL_DIR_ERR" | head -1 | LC_ALL=C tr -d '\n' | LC_ALL=C tr '\000-\037\177' ' ')
  fi
  [ -n "$GOAL_LIST" ] && GOAL_FILES=$(printf '%s\n' "$GOAL_LIST" | wc -l | tr -d ' ')
  # No run is read through a symlink either: the runtime directory, its runs
  # or a run directory committed as one belongs to the target of the link. A refused
  # run is left out, with a note on stderr.
  RUN_FILES=0
  RUN_LIST=""
  VERDICT_LIST=""
  RUN_DIR_RC=0
  RUN_DIR_ERR=$("${HELPER%/cascade-resolve.sh}/flow-mkdir.sh" --check -- "$RT/runs" 2>&1) || RUN_DIR_RC=$?
  RUN_DIR_ERR=${RUN_DIR_ERR#flow-mkdir.sh: }
  RUN_DIR_ERR=${RUN_DIR_ERR%$'\r'}
  if [ "$RUN_DIR_RC" -eq 0 ]; then
    if [ -d "$RT/runs" ]; then
      find "$RT/runs" -mindepth 1 -maxdepth 1 -type l 2>/dev/null | LC_ALL=C sort |
        while IFS= read -r RUN_LINK; do
          printf 'refusing — %s is a symlink; runs are not read through it\n' "$RUN_LINK" >&2
        done
      RUN_LIST=$(find "$RT/runs" -name "events.jsonl" ! -type l 2>/dev/null | LC_ALL=C sort)
      # The last verdict of each run, for the stuck-detection pattern, listed the same
      # way: never one that is a symlink.
      VERDICT_LIST=$(find "$RT/runs" -name "last-verdict.json" ! -type l 2>/dev/null | LC_ALL=C sort)
    fi
  elif [ "$RUN_DIR_RC" -eq 2 ]; then
    printf '%s; runs are not read through it\n' "${RUN_DIR_ERR%"; nothing is written under it"}" >&2
  elif [ -z "$LEARN_UNCHECKED" ]; then
    LEARN_UNCHECKED=$(printf '%s' "$RUN_DIR_ERR" | head -1 | LC_ALL=C tr -d '\n' | LC_ALL=C tr '\000-\037\177' ' ')
  fi
  [ -n "$RUN_LIST" ] && RUN_FILES=$(printf '%s\n' "$RUN_LIST" | wc -l | tr -d ' ')
  if [ -n "$LEARN_UNCHECKED" ]; then
    printf '%s\n' "STATE=unavailable"
    printf '%s\n' "REASON=$LEARN_UNCHECKED, so which goal files and run events can be read is unknown"
  else
    printf '%s\n' "GOAL_FILE_COUNT=$GOAL_FILES"
    printf '%s\n' "RUN_EVENT_FILE_COUNT=$RUN_FILES"
    if [ "$GOAL_FILES" = "0" ] && [ "$RUN_FILES" = "0" ]; then
      printf '%s\n' "STATE=empty"
    else
      printf '%s\n' "STATE=ok"
      [ -n "$GOAL_LIST" ] && printf '%s\n' "$GOAL_LIST" | sed 's/^/GOAL_FILE=/'
      [ -n "$RUN_LIST" ] && printf '%s\n' "$RUN_LIST" | sed 's/^/RUN_EVENTS=/'
      [ -n "$VERDICT_LIST" ] && printf '%s\n' "$VERDICT_LIST" | sed 's/^/RUN_VERDICT=/'
    fi
  fi
fi

# Section: Transcript Corrections
# TRANSCRIPT_CORRECTIONS_BLOCK_BEGIN
# learning.sources (JSON array, default ["journal","transcripts"]) selects the
# evidence sources this command reads. Session transcripts are the Claude Code
# own logs under <config>/projects/<slug>/, <config> being $CLAUDE_CONFIG_DIR when you set it, or
# ~/.claude (override: learning.transcriptDir,
# empty = auto) — read-only, user-scoped, never written here. The miner keeps
# recall-oriented candidates; Phase 2 does the judging.
printf '%s\n' ""
printf '%s\n' "### Transcript Corrections"
LEARN_SOURCES='["journal","transcripts"]'
[ -x "$HELPER" ] && LEARN_SOURCES=$("$HELPER" --compact --default '["journal","transcripts"]' '.learning.sources // empty' 2>/dev/null)
printf '%s\n' "TRANSCRIPT_SOURCES=$LEARN_SOURCES"
TRANSCRIPTS_ON="false"
if command -v jq >/dev/null 2>&1; then
  TRANSCRIPTS_ON=$(printf '%s' "$LEARN_SOURCES" | jq -r 'type == "array" and any(.[]; . == "transcripts")' 2>/dev/null)
else
  case "$LEARN_SOURCES" in *transcripts*) TRANSCRIPTS_ON="true" ;; esac
fi
MINER="$(dirname "$HELPER")/flow-mine-corrections.sh"
TRANSCRIPT_DIR_SETTING=""
# Only the user settings file and the plugin default may name the transcript
# directory: a repository setting could point the miner at transcripts it
# ships. A value that is not absolute after ~ is expanded is not used.
# USER_FILES_BEGIN
USER_HELPER="$(__t=$(git rev-parse --show-toplevel 2>/dev/null);__x=0;[ -z "$__t" ]||{ __t=$(cd "$__t" 2>/dev/null&&pwd -P);[ -n "$__t" ]||__x=1; };[ "$__x" = 1 ]||{ printf '%s\n' "${CLAUDE_PLUGIN_ROOT:-}";ls -d "${CLAUDE_CONFIG_DIR:-$HOME/.claude}"/plugins/cache/synapti-marketplace/flow/*/ 2>/dev/null|sort -Vr;printf '%s\n' "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/plugins/marketplaces/synapti-marketplace/plugins/flow"; }|while read -r __p;do __p=${__p%/};[ -n "$__p" ]&&[ -x "$__p/bin/cascade-resolve.sh" ]||continue;__r=$(cd "$__p" 2>/dev/null&&pwd -P)||continue;[ -n "$__r" ]||continue;[ -z "$__t" ]||{ __d=$__r;__in=0;while :;do [ "$__d" -ef "$__t" ]&&{ __in=1;break; };[ "$__d" = / ]&&break;__d=$(dirname "$__d");done;[ "$__in" = 1 ]&&continue; };printf '%s\n' "$__r";break;done)/bin/cascade-resolve.sh"
# USER_FILES_END
if [ -x "$USER_HELPER" ]; then
  TRANSCRIPT_DIR_SETTING=$("$USER_HELPER" --no-repo-settings --default "" '.learning.transcriptDir // empty') ||
    { TRANSCRIPT_DIR_SETTING=""; printf '%s\n' "WARN=learning.transcriptDir could not be read from the user settings; using the default roots"; }
else
  printf '%s\n' "WARN=learning.transcriptDir could not be read from the user settings (no installed flow outside this repository answered); using the default roots"
fi
USER_HOME=""
[ -x "$USER_HELPER" ] && USER_HOME=$("$USER_HELPER" --user-home 2>/dev/null)
case "$USER_HOME" in /*) ;; *) USER_HOME=/nonexistent ;; esac
TRANSCRIPT_DIR_SETTING="${TRANSCRIPT_DIR_SETTING/#\~/$USER_HOME}"
case "$TRANSCRIPT_DIR_SETTING" in
  /*|'') ;;
  *) printf '%s\n' "WARN=learning.transcriptDir is not an absolute path or one under ~; using the default roots"
     TRANSCRIPT_DIR_SETTING="" ;;
esac
if [ "$TRANSCRIPTS_ON" != "true" ]; then
  printf '%s\n' "TRANSCRIPT_STATE=disabled"
  printf '%s\n' "CANDIDATE_COUNT=0"
elif [ ! -x "$MINER" ]; then
  printf '%s\n' "TRANSCRIPT_STATE=missing"
  printf '%s\n' "ERROR=flow-mine-corrections.sh missing or non-executable next to cascade-resolve.sh"
  printf '%s\n' "CANDIDATE_COUNT=0"
else
  if [ -n "$TRANSCRIPT_DIR_SETTING" ]; then
    MINER_OUT=$("$MINER" --format markdown --max-sessions 50 --transcript-dir "$TRANSCRIPT_DIR_SETTING" 2>/dev/null)
  else
    MINER_OUT=$("$MINER" --format markdown --max-sessions 50 2>/dev/null)
  fi
  # System One screening (site learn.correction, references/system-one.md).
  # The state sent for each candidate is the user turn as typed (up to 600
  # characters) and the first 300 characters of the last assistant message
  # before it. Nothing in that text is removed or replaced first: a key or
  # password typed into the turn is sent with it. With provider typesafe it
  # goes to the TypeSafe hosted API, with custom (or imajev at an address off
  # this machine) to the server at baseUrl, and with imajev at its default
  # local address it stays on this machine. The mode comes from
  # flow-s1-mode.sh, the one place that applies the mode rule: a repository
  # can lower the mode set in the user settings or the plugin default, but
  # never start the sending, and with no provider configured the site is off.
  # The screening runs the miner again with --format jsonl and asks about each
  # candidate; the miner itself sends nothing. That miner, flow-s1-mode.sh,
  # flow-s1.sh and the screener all come from the installed copy of the plugin
  # outside the repository, so code the repository ships never chooses the
  # text that is sent. Only when at least one candidate was answered, which
  # happens in on mode alone, does it print the section again with the rows
  # reordered (rated corrections first, then unanswered, then rated
  # non-corrections) and four S1_ lines. Otherwise, in shadow mode or when no
  # call answered, the section below prints what the miner printed; a fault in
  # the screener adds one WARN= line. The screener runs in the background and
  # this shell waits for it, so a TERM, INT or HUP stops it (and the call it
  # has in progress) and removes the temporary files, which hold transcript
  # text, before the shell exits.
  LEARN_S1_MODE=off
  LEARN_S1_BIN="$(dirname "$USER_HELPER")"
  if [ -n "$MINER_OUT" ] && [ -x "$USER_HELPER" ] && [ -x "$LEARN_S1_BIN/flow-s1-mode.sh" ] && [ -x "$LEARN_S1_BIN/flow-s1.sh" ] && [ -x "$LEARN_S1_BIN/flow-mine-corrections.sh" ] && [ -f "$LEARN_S1_BIN/_flow_learn_s1.py" ] && command -v python3 >/dev/null 2>&1; then
    LEARN_S1_MODE=$("$LEARN_S1_BIN/flow-s1-mode.sh" learn.correction 2>/dev/null) || LEARN_S1_MODE=off
  fi
  case "$LEARN_S1_MODE" in
    shadow|on)
      LEARN_S1_TMP=""
      LEARN_S1_PID=""
      _learn_s1_clean() {
        if [ -n "$LEARN_S1_PID" ]; then
          kill -TERM "$LEARN_S1_PID" 2>/dev/null
          wait "$LEARN_S1_PID" 2>/dev/null
          LEARN_S1_PID=""
        fi
        [ -n "$LEARN_S1_TMP" ] && { rm "$LEARN_S1_TMP/table.md" "$LEARN_S1_TMP/out" "$LEARN_S1_TMP/err" 2>/dev/null; rmdir "$LEARN_S1_TMP" 2>/dev/null; }
      }
      trap '_learn_s1_clean; exit 129' HUP
      trap '_learn_s1_clean; exit 130' INT
      trap '_learn_s1_clean; exit 143' TERM
      # A template, so TMPDIR is used on macOS too: mktemp -d alone ignores it
      # there.
      LEARN_S1_TMP=$(mktemp -d "${TMPDIR:-/tmp}/flow-learn-s1.XXXXXX" 2>/dev/null) || LEARN_S1_TMP=""
      if [ -n "$LEARN_S1_TMP" ] && printf '%s' "$MINER_OUT" > "$LEARN_S1_TMP/table.md" 2>/dev/null; then
        PYTHONSAFEPATH=1 python3 "$LEARN_S1_BIN/_flow_learn_s1.py" screen --table "$LEARN_S1_TMP/table.md" --miner "$LEARN_S1_BIN/flow-mine-corrections.sh" --flow-s1 "$LEARN_S1_BIN/flow-s1.sh" --transcript-dir "$TRANSCRIPT_DIR_SETTING" > "$LEARN_S1_TMP/out" 2> "$LEARN_S1_TMP/err" &
        LEARN_S1_PID=$!
        wait "$LEARN_S1_PID"
        LEARN_S1_RC=$?
        LEARN_S1_PID=""
        # Only the exception type the screener names is printed, never other
        # text from its stderr.
        LEARN_S1_FAIL=$(sed -n 's/^flow-learn-s1: WARN: screening failed: \([A-Za-z0-9_]\{1,64\}\)$/\1/p' "$LEARN_S1_TMP/err" 2>/dev/null | head -n 1)
        [ -n "$LEARN_S1_FAIL" ] || [ "$LEARN_S1_RC" -eq 0 ] || LEARN_S1_FAIL="exit $LEARN_S1_RC"
        # The screener's output replaces the miner's only when it exited 0 and
        # named no fault: a run that failed part way through its write leaves
        # a table with rows missing.
        if [ -z "$LEARN_S1_FAIL" ]; then
          LEARN_S1_OUT=$(cat "$LEARN_S1_TMP/out" 2>/dev/null) || LEARN_S1_OUT=""
          [ -n "$LEARN_S1_OUT" ] && MINER_OUT=$LEARN_S1_OUT
        else
          printf '%s\n' "WARN=System One screening failed ($LEARN_S1_FAIL); the candidates are in the miner's order"
        fi
      fi
      _learn_s1_clean
      trap - HUP INT TERM
      ;;
  esac
  case "$MINER_OUT" in
    *TRANSCRIPT_DIR_STATE=ok*) printf '%s\n' "TRANSCRIPT_STATE=ok" ;;
    *) printf '%s\n' "TRANSCRIPT_STATE=missing" ;;
  esac
  if [ -n "$MINER_OUT" ]; then
    printf '%s\n' "$MINER_OUT"
  else
    printf '%s\n' "ERROR=flow-mine-corrections.sh produced no output"
    printf '%s\n' "CANDIDATE_COUNT=0"
  fi
fi
# TRANSCRIPT_CORRECTIONS_BLOCK_END

# Section: Dismissal Artifacts
printf '%s\n' ""
printf '%s\n' "### Dismissal Artifacts"
# DISMISSAL_ARTIFACTS_BLOCK_BEGIN
# Findings the team rejected. `review.md` and `pr.md` write `dropped-finding`
# artifacts and `address.md` writes `finding-dismissed` artifacts to the
# journal manifest; this block reads that manifest rather than the freeform
# body.
#
# The two types are different records and both matter: `dropped-finding` says a
# finding did not survive the review machinery, `finding-dismissed` says a human
# rejected it on stated grounds. Only the second is evidence for an exception,
# so they are counted apart.
DISMISSAL_JOURNAL_DIR="${JOURNAL_DIR:-.decisions}"
# The reader is bin/_journal_manifest.py, shared with the DISPUTED_ARRAY_BLOCK
# in address.md and taking its fence predicate from bin/_journal_atomic.py.
# Resolved the same way every other helper in this command is.
# No apostrophes in these comments: this is an inline-! block, and an unpaired
# one kills the whole block on the Windows executor.
FLOW_ROOT="$(__fr="${CLAUDE_PLUGIN_ROOT:-}";[ -x "$__fr/bin/cascade-resolve.sh" ]||__fr=$({ printf '%s\n' plugins/flow;ls -d "${CLAUDE_CONFIG_DIR:-$HOME/.claude}"/plugins/cache/synapti-marketplace/flow/*/ 2>/dev/null|sort -Vr;printf '%s\n' "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/plugins/marketplaces/synapti-marketplace/plugins/flow"; }|while read -r __p;do [ -x "${__p%/}/bin/cascade-resolve.sh" ]&&{ printf '%s\n' "${__p%/}";break;};done);printf '%s\n' "$__fr")"
# Probed for the same reason PyYAML is below: the import sits above the first
# print, so on an install where the reader is missing this block would die
# before emitting any STATE line — and a missing STATE line reads exactly like
# a project that has dismissed nothing.
if [ ! -f "$FLOW_ROOT/bin/_journal_manifest.py" ]; then
  printf '%s\n' "DISMISSED_COUNT=0"
  printf '%s\n' "DROPPED_COUNT=0"
  printf '%s\n' "STATE=unavailable"
  printf '%s\n' "REASON=the shared journal reader could not be located, so whether this project has recorded dismissals is unknown"
else
# Probe before the heredoc. `import yaml` sits above the try below, so a machine
# without PyYAML dies before the first print and the section is a bare heading —
# no STATE line at all, which Phase 2 reads as "this project has dismissed
# nothing". Every sibling block in start.md and status.md probes first.
if ! command -v python3 >/dev/null 2>&1 || \
     ! PYTHONSAFEPATH=1 python3 -c 'import os, sys; sys.path[:] = [p for p in sys.path if p and os.path.isabs(p) and not (os.path.isdir(p) and os.access(os.curdir, os.X_OK) and os.path.samefile(p, os.curdir))]; import yaml' >/dev/null 2>&1; then
  printf '%s\n' "DISMISSED_COUNT=0"
  printf '%s\n' "DROPPED_COUNT=0"
  printf '%s\n' "STATE=unavailable"
  printf '%s\n' "REASON=python3 with PyYAML is required to read the journal manifests, so whether this project has recorded dismissals is unknown"
else
DISMISSAL_OUT=$(PYTHONSAFEPATH=1 python3 - "$FLOW_ROOT/bin" "$DISMISSAL_JOURNAL_DIR" <<'DISMISSAL_PY'
# Keep the working directory (the repository) off sys.path before any other
# import; tests/syspath-guard.test.sh has the reasons.
import os, sys
try:
    _flow_cwd = os.path.realpath(os.getcwd())
except OSError:
    _flow_cwd = None
sys.path[:] = [p for p in sys.path if p and os.path.isabs(p) and os.path.realpath(p) != _flow_cwd]
import sys

# The reader lives in the bin/ directory of the plugin, and takes its fence
# predicate from bin/_journal_atomic.py — the module every journal write goes
# through. This block keeps no copy of either: a copy here would drift from the
# reader it copies.
sys.path.insert(0, sys.argv[1])

import errno
import os

from _journal_manifest import ManifestError, one_line, read_artifacts

journal_dir = sys.argv[2]

if not os.path.isdir(journal_dir):
    # A directory that is not there is not a project with no dismissals. The
    # journal dir comes from the settings cascade and falls back to a RELATIVE
    # .decisions, so running from a subdirectory reproduces this.
    print("DISMISSED_COUNT=0")
    print("DROPPED_COUNT=0")
    print("STATE=unavailable")
    # Through one_line: journal.dir is read from .claude/settings.flow.json, a
    # tracked file, so a fork pull request chooses this string.
    print("REASON=the journal directory %s does not exist, so whether this project has "
          "recorded dismissals is unknown" % one_line(journal_dir))
    sys.exit(0)

dismissed = []
dropped = []
unreadable = []

# os.listdir, not glob, for two reasons:
#
#   1. glob swallows the OSError from a directory it cannot read and returns an
#      empty list, so a directory holding recorded dismissals that the process
#      may not list would report DISMISSED_COUNT=0 / STATE=empty, the same
#      answer a project with nothing recorded gives.
#   2. glob reads [ ? and * inside the pattern as syntax, so a directory name
#      holding one of them would need escaping.
#
# listdir raises for the first and needs no escaping for the second. Names
# starting with a dot are skipped, as `*` skips them in glob, so a
# `.hidden.md` in the journal directory is ignored.
try:
    _entries = sorted(os.listdir(journal_dir))
except OSError as exc:
    print("DISMISSED_COUNT=0")
    print("DROPPED_COUNT=0")
    print("STATE=unavailable")
    print("REASON=the journal directory %s could not be listed (%s), so whether this "
          "project has recorded dismissals is unknown" % (one_line(journal_dir), errno.errorcode.get(exc.errno, "OSError")))
    sys.exit(0)

for _name in _entries:
    if _name.startswith(".") or not _name.endswith(".md"):
        continue
    path = os.path.join(journal_dir, _name)
    try:
        for a in read_artifacts(path):
            if not isinstance(a, dict):
                # One silently dropped entry can decide whether a cluster
                # reaches the two-instance threshold.
                unreadable.append((path, "an artifacts entry is %s, not a mapping" % type(a).__name__))
                continue
            t = a.get("type")
            if t == "finding-dismissed":
                dismissed.append((path, a))
            elif t == "dropped-finding":
                dropped.append((path, a))
    except ManifestError as exc:
        # A manifest nobody could read is not a project with no dismissals.
        # Counting it as zero would hide the evidence this category exists to
        # find. A journal with
        # no frontmatter at all is NOT this case — read_artifacts returns [] for
        # it, because the writer prepends a manifest on the first write and a
        # file without one has had nothing recorded in it.
        unreadable.append((path, exc))
    except Exception as exc:
        # Not ours, so only the class goes out: the text of a parse error quotes
        # the file, and the file may not be a manifest at all.
        unreadable.append((path, "the manifest could not be read (%s); its text is not "
                                 "echoed here" % type(exc).__name__))

for path, exc in unreadable:
    print("JOURNAL_UNREADABLE=%s — %s" % (one_line(path), one_line(exc)))
print("DISMISSED_COUNT=%d" % len(dismissed))
print("DROPPED_COUNT=%d" % len(dropped))
if unreadable:
    print("STATE=degraded")
    print("REASON=%d journal file(s) could not be read, so the counts above are a floor, not a total" % len(unreadable))
elif not dismissed and not dropped:
    print("STATE=empty")
else:
    print("STATE=ok")
for path, a in dismissed:
    print("DISMISSED=journal=%s pr=%s cycle=%s finding_id=%s category=%s reason=%s by=%s" % (
        one_line(path), one_line(a.get("pr")), one_line(a.get("cycle")),
        one_line(a.get("finding_id")), one_line(a.get("category")),
        one_line(a.get("reason")), one_line(a.get("by"))))
for path, a in dropped:
    print("DROPPED=journal=%s pr=%s cycle=%s finding_id=%s facet=%s reason=%s" % (
        one_line(path), one_line(a.get("pr")), one_line(a.get("cycle")),
        one_line(a.get("finding_id")), one_line(a.get("facet")),
        one_line(a.get("reason"))))
DISMISSAL_PY
); DISMISSAL_RC=$?
  # A reader that died mutely leaves no STATE line, which reads as a project
  # with nothing to report.
  if [ "$DISMISSAL_RC" -ne 0 ] || [ "$(printf '%s\n' "$DISMISSAL_OUT" | grep -c '^STATE=')" != "1" ]; then
    printf '%s\n' "DISMISSED_COUNT=0"
    printf '%s\n' "DROPPED_COUNT=0"
    printf '%s\n' "STATE=unavailable"
    printf '%s\n' "REASON=the dismissal reader did not complete (exit $DISMISSAL_RC), so whether this project has recorded dismissals is unknown"
  else
    printf '%s\n' "$DISMISSAL_OUT"
  fi
fi
fi
# DISMISSAL_ARTIFACTS_BLOCK_END

true

Read the full file on GitHub · 739 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 25d ago Changed · +5 lines d745c9912235
  2. 1mo ago Changed · +7 lines b2b9f1f04756
  3. 1mo ago Changed · -8 lines fb684d045bda
  4. 1mo ago Changed · +87 lines 97058fc00c59
  5. 2mo ago Changed · +50 lines 43325153cf82
  6. 2mo ago Changed · +72 lines 76619a59a8e0
  7. 2mo ago Changed · +1 lines 21a30c8fb5db
  8. 2mo ago Changed 42d3ace45039
  9. 2mo ago Changed · +229 lines b877b0df8e99
  10. 2mo ago First seen · 296 lines · 35 tokens per session scan A 08d42005103d

Subscribe to this mod's changes

learn is a command published in the GitHub repository synaptiai/synapti-marketplace (9 stars, last pushed today), licensed Apache-2.0. It adds 35 tokens to every session and 14,262 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

learn compared with commands from other repositories

learn next to 6 commands from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
learnsynaptiai/synapti-marketplaceCommand9todayApache-2.0A35Claude Code
paper-trail-resolve-textbooksroomi-fields/paper-trailCommand83mo agoMITA62Claude Code
create-worktreeCaptainMe-AI/lead-dev-osCommand224d agoMITA0Claude Code
learn-modeShaheerKhawaja/ProductionOSCommand87mo agoMITA43Claude Code
naksha-helpAdityaraj0421/naksha-studioCommand3591mo agoMITA17Claude Code
altOPTIMETA/PAIDEIACommand934mo agoMITA44Claude Code
hwmapOPTIMETA/PAIDEIACommand934mo agoMITA26Claude Code