agentleFS
rillmdrillmd/rill/skills/distill/SKILL.md

distill

Skill9 starsChanged 42 days agoMITView on GitHub

Unified distillation pipeline: process inbox sources (journal, meetings, tweets, web-clips, think-outputs) into knowledge notes, task candidates, and entity updates, then refresh queued note metadata. Use when the user asks to distill, process the inbox, or extract knowledge and tasks from recent inputs.

77 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use layout, shape and 9 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • owshq-mecSkill

    layout

    Improve layout, spacing, and visual rhythm. Fixes monotonous grids, inconsistent spacing, and weak visual hierarchy. Use when the user mentions layout feeling off, spacing issues, visual hierarchy, crowded UI, alignment problems, or wanting better composition.

    Also in 8 projects that use this

  • HAR5HA-7663Skill

    shape

    Plan the UX and UI for a feature before writing code. Runs a structured discovery interview, then produces a design brief that guides implementation. Use during the planning phase to establish design direction, constraints, and strategy before any code is written.

    Also in 11 projects that use this

  • klauswgSkill

    ckm:design-system

    Token architecture, component specifications, and slide generation. Three-layer tokens (primitive→semantic→component), CSS variables, spacing/typography scales, component specs, strategic slide creation. Use for design tokens, systematic design, brand-compliant presentations.

    Also in 3 projects that use this

  • iovisorSkill

    evolve

    Evolve uBPF through a gated spec-first workflow that propagates approved changes through requirements, design, validation, implementation, and RFC alignment artifacts.

    Also in 3 projects that use this

  • termdockSkill

    recall

    Retrieves cross-session memories about past decisions, lessons, and patterns. Use when user asks about prior work, past decisions, or mentions a feature. Triggers include check memory, what did we decide, how did we solve.

    Also in 6 projects that use this

  • bidodevSkill

    devils-advocate

    Challenges decisions, plans, and code by systematically arguing the opposing side. Surfaces risks, pokes holes in assumptions, and stress-tests thinking before committing. Supports intensity levels (gentle, balanced, ruthless, linus) and works with conversation context or a specific file reference. Trigger on requests like "challenge this", "poke holes", "what could go wrong", "play devil's advocate", "linus mode", or "/devils-advocate".

    Also in 3 projects that use this

The file

Show its rules and text

We split this skill into the rules it gives an agent

34 rules. 0 are common, 14 are distinctive, and 20 are very specific to this project.

  • 0

    Common

    Most of the 73 edited versions we read keep these.

  • 14

    Distinctive

    This author's own choices. Worth a look.

  • 20

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    File path: Run single-file distillation on the specified file (e.g., reports/newsletter/2026-03-20.md)

    line 27
  2. Distinctive:

    Directory path: Run single-file distillation on all .md files in the directory

    line 28
  3. Distinctive:

    When the argument is a file or directory, execute the following:

    line 34
  4. Very specific:

    Target determination: Check if the argument is a workspace/*/ directory

    line 37
  5. Distinctive:

    When a file or non-workspace directory is specified.

    line 43
  6. Very specific:

    Resolve target files: If directory, target all .md files inside (exclude _workspace.md, _summary.md, _distill.md, _organized/).

    line 45
  7. Very specific:

    Entity detection: If newly created knowledge/notes/ mentions reference entities not in knowledge/people/ or knowledge/orgs/, auto-create …

    line 47
  8. Very specific:

    Post-processing: Run rill strip-entity-tags on created knowledge/notes/, append new tags to taxonomy.md

    line 49
  9. Very specific:

    Read the "Topic Tags" table from taxonomy.md and generate YAML list format (name + desc) (exclude deprecated tags).

    line 59
  10. Very specific:

    Read .claude/commands/_distill/task-extraction.md and store contents in {task_extraction_rules} variable (single definition of task …

    line 68
  11. Distinctive:

    After the Tier dict, check whether monthly Tier 1 curation review should fire this run (artifact 013 §4 + 015 §4):

    line 83
  12. Very specific:

    If TIER1_CURATION_DUE=1, Step 7.5 (below) will fire after Group 2 completes.

    line 110
  13. Very specific:

    Refresh queue check: Read knowledge/.refresh-queue.

    line 205
  14. Very specific:

    Read plugins/.enabled to get the list of enabled plugins.

    line 216
  15. Distinctive:

    After all agents complete:

    line 265
  16. Very specific:

    Update .processed via rill processed set (do not record files that errored.

    line 266
  17. Very specific:

    Entity ID stripping (deterministic post-processing): Run rill strip-entity-tags <file-paths ...> on created/updated knowledge/notes/ …

    line 271
  18. Very specific:

    If new tags are reported, append to taxonomy.md (verify no conflict with deprecated tags)

    line 273
  19. Very specific:

    Read participants: and tags: from inbox/*/_organized/ files processed in Group 1

    line 280
  20. Very specific:

    Only Grep knowledge/people/ for participants not found in mapping

    line 282
  21. Distinctive:

    If corresponding people/ company field is a string, update to orgs/ id

    line 286
  22. Distinctive:

    Keep created entity IDs consistent with taxonomy.md tags

    line 287
  23. Distinctive:

    If no candidates, display "No knowledge extraction candidates" and skip

    line 292
  24. Very specific:

    Run rill strip-entity-tags on knowledge/notes/ created in Phase 3

    line 298
  25. Distinctive:

    After the review file is written (or the iteration completes with zero flagged entities), update the state file:

    line 351
  26. Very specific:

    When inject_args (from Step 1.6) is non-empty, append it to the agent's prompt alongside the processing-results summary.

    line 388
  27. Very specific:

    Phase 5: Read plugins/.enabled. For each enabled plugin, check if plugins/{name}/hooks/post-distill.md exists.

    line 390
  28. Distinctive:

    After all Phases complete, before the final summary:

    line 399
  29. Distinctive:

    If the aggregated list is empty, skip this step

    line 406
  30. Distinctive:

    Write the aggregated paths to a temporary sources file (one per line, absolute or repo-relative paths both accepted by the CLI), then …

    line 407
  31. Very specific:

    Do NOT pass --force blindly: If the CLI prints ⚠ bulk update detected, the aggregated list is likely contaminated with Evergreen updates …

    line 415
  32. Distinctive:

    After all Phases complete, display the following summary:

    line 421
  33. Very specific:

    After Step 10 (Summary) completes, invoke /pulse via the harness's Skill tool to refresh knowledge/self/current-state.md.

    line 432
  34. Distinctive:

    If the /pulse invocation fails for any reason, log a 1-line warning to stdout and continue — /pulse refresh failure is not fatal to …

    line 442

“Common” is measured: kept by at least 6 in 10 of the 73 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

/distill — Unified Distillation Command

Conduct all conversation with the user — and write all generated output — in the language defined by .claude/rules/personal-language.md (or the user's input language if that file is absent). Follow the language rules in full — exceptions and translation quality are defined in the Language Rules of .claude/rules/rill-core.md and the vault's personal-*.md overrides, never restated per skill. The English instructions below are for skill clarity, not for output style.

Tool references in this skill (Read, Grep, Glob, the Agent tool, model: "sonnet", run_in_background) describe intent, not Claude-specific tool calls. Each harness should map them to its native equivalent. On Codex CLI: sub-agent fan-out (the parallel Agent launches below) maps to Codex's own sub-agent mechanism where one is available, or runs sequentially in the current session when it isn't; run_in_background likewise degrades to sequential execution when no background/async primitive exists; a named model is a preference for an equivalent lighter/faster model, falling back to the session default. If a step asks the user a question, treat it as a plain free-text question in an interactive session; in an unattended run it must not block — write a [DECISION-QUEUE] entry instead, per the decision-loop contract (ADR-084, .claude/rules/rill-autonomous-execution.md §9).

Batch-processes unprocessed inbox/journal/ and inbox/*/ files. Uses flat orchestrator pattern with external templates + parallel agent spawning (D48). Workspace distillation is handled by /close in the parent context (ADR-072).

Arguments

$ARGUMENTS — one of the following:

  • Omitted: Auto-detect unprocessed files and run the full pipeline
  • File path: Run single-file distillation on the specified file (e.g., reports/newsletter/2026-03-20.md)
  • Directory path: Run single-file distillation on all .md files in the directory

Procedure

Single-File Mode (with arguments)

When the argument is a file or directory, execute the following:

  1. Shared context preparation (same as Step 1 of batch mode)
  2. Target determination: Check if the argument is a workspace/*/ directory
    • If workspace directory → Display "Workspace distillation is handled by /close. Use /close {workspace-id}" and exit (ADR-072)
    • Otherwise → Normal distillation mode (below)

Normal Distillation Mode

When a file or non-workspace directory is specified.

  1. Resolve target files: If directory, target all .md files inside (exclude _workspace.md, _summary.md, _distill.md, _organized/). If _organized/ has a file with the same name, prefer that one
  2. Knowledge extraction: Launch an Agent per target file (_distill/knowledge-agent.md template + shared context injection; launch the whole set in the background and let the harness cap effective concurrency — no fixed-size pool). When inject_args (from Step 1.6) is non-empty, append it to each agent's prompt
  3. Entity detection: If newly created knowledge/notes/ mentions reference entities not in knowledge/people/ or knowledge/orgs/, auto-create them (Phase 2.5 equivalent)
  4. Task extraction: For each target file, launch _task/create-agent.md as a sub-agent in mode=extract (launched in the background, harness-capped concurrency) with model: "sonnet" (Tier 2 LLM-as-judge eval, 2026-04-19: 3/3 decision agreement with Opus baseline including correct ENRICH-vs-CREATE judgment on a thin-duplicate case and correct skip discipline on a 4-item committed/speculative mix; 0/3 DEGRADED-MAJOR; cost reduced ~24% vs Opus on this workload, larger savings expected in production where cache effects are smaller). Pass source_path = the target file, the shared context (taxonomy + entity mappings), and the list of knowledge/notes/ paths created in step 2 as hints. The sub-agent owns duplicate checking, substance writing, and file creation per .claude/rules/rill-tasks.md. It sets status=draft via rill mkfile --field (ADR-069)
  5. Post-processing: Run rill strip-entity-tags on created knowledge/notes/, append new tags to taxonomy.md
  6. Summary display: List of created knowledge, entity creation count, added tasks

※ Organized version creation (Phase 2) is not executed (target files are assumed already structured) ※ Profile update (Phase 4) and Plugin hooks (Phase 5) are not executed

Batch Pipeline Mode (no arguments)

Step 1: Shared Context Preparation (once in parent context)

  • Read the "Topic Tags" table from taxonomy.md and generate YAML list format (name + desc) (exclude deprecated tags). Example: - name: api-design\n desc: API, interface, and protocol design Important: Tag vocabulary must always be passed in YAML list format. Inline format like tag(description) is prohibited (ADR-046 D46-3)
  • Run rill context-map once and capture its output (deterministic, 0 LLM tokens, sub-second — it reads only frontmatter, never file bodies). It emits five sections that supply the rest of the shared context without any parent-context file reads:
    • ### People mapping → {people_mapping} (extended one-line format people/jane-smith: Jane Smith | aliases: Jane,J. Smith | company: acme-corp, type prefix per ADR-053)
    • ### Orgs mapping → {orgs_mapping} (orgs/acme-corp: Acme Corporation (Acme,Acme Inc))
    • ### Projects mapping → {projects_mapping} (projects/phoenix: Project Phoenix (active, tags: infrastructure); ADR-080 per-directory layout)
    • ### Entity IDs → the entity-ID list used for entity stripping in post-processing
    • ### Tier dict → the tier_assignment block injected into Group 2 (knowledge-agent) for Tier-aware processing (see the Tier dict note below)
    • Do not re-read knowledge/{people,orgs}/*.md or projects/*/_project.md in the parent — rill context-map replaces the old per-run ~620 KB compression pass (container files CLAUDE.md/AGENTS.md and files without top-of-file frontmatter are ignored)
  • Read .claude/commands/_distill/task-extraction.md and store contents in {task_extraction_rules} variable (single definition of task extraction rules)
  • ※ Do not generate knowledge/notes/ filename list (each agent explores via Glob/Grep, D48-2)
  • ※ Task duplicate checking is done by parent context in batch (scan existing tickets in tasks/)
  • Important: Do not read target file contents in parent context. Pass only file paths to agents, let agents Read internally

Tier dict (from rill context-map)

The ### Tier dict section emitted by rill context-map (Step 1 above) is the entity Tier dict — per-entity mention counts across the vault, bucketed tier1 (≥8) / tier2 (≥3) / tier3, with a tier_assignment block. It is computed deterministically in a single awk pass (0 LLM tokens, sub-second) and replaces the former inline Bash that spawned a subprocess per file (artifact 013 §5.3). The CLI owns the scope (inbox/*/_organized + inbox/think-outputs + workspace + tasks + knowledge/notes + reports/{daily,newsletter}; entity self-reference dirs excluded), the thresholds, and the mentions: parse (both inline [a, b] and block-list forms; files without top-of-file frontmatter are ignored, so fenced examples in CLAUDE.md never leak phantom counts).

Inject the tier_assignment block into the shared context passed to Group 2 (_distill/knowledge-agent.md) for Tier-aware processing (artifact 013 §6.1).

Ordering tradeoff: the dict reflects vault state at Step 1 (before inbox files are organized in Step 4). An entity that crosses a tier boundary via this run's newly-organized files is captured on the next /distill invocation — an accepted Phase 1 limitation (the Step 1.5 curation cadence only fires monthly).

Step 1.5: Tier 1 monthly curation cadence judgment (NEW)

After the Tier dict, check whether monthly Tier 1 curation review should fire this run (artifact 013 §4 + 015 §4):

STATE_FILE=".claude/state/distill-tier1-curation.json"
if [[ -f "$STATE_FILE" ]]; then
  # Allow optional whitespace after the JSON key colon (Step 7.5 writes pretty-printed JSON with one space)
  last_ts=$(grep -oE '"last_curation_at":[[:space:]]*"[^"]+"' "$STATE_FILE" | grep -oE '"20[0-9T:+\-]+"' | tr -d '"' || echo "")
else
  last_ts=""
fi

if [[ -z "$last_ts" ]]; then
  TIER1_CURATION_DUE=1     # never run before → due
else
  # Step 7.5 writes last_curation_at via `date -Iseconds` which on macOS emits +09:00 (colon-separated TZ).
  # Normalize +09:00 → +0900 before parsing so the %z format actually matches; fall back to 999 days on parse failure.
  norm_ts=$(echo "${last_ts}" | sed -E 's/([+-][0-9]{2}):([0-9]{2})$/\1\2/')
  parsed=$(date -j -f "%Y-%m-%dT%H:%M:%S%z" "${norm_ts}" +%s 2>/dev/null || echo 0)
  if [[ "${parsed}" == "0" ]]; then
    days_since=999      # parse failure → treat as overdue (safe default)
  else
    days_since=$(( ($(date +%s) - parsed) / 86400 ))
  fi
  if (( days_since >= 30 )); then TIER1_CURATION_DUE=1; else TIER1_CURATION_DUE=0; fi
fi

If TIER1_CURATION_DUE=1, Step 7.5 (below) will fire after Group 2 completes. Otherwise Step 7.5 is silently skipped.

Day-of-week guard: To avoid same-session collision with /retrospective (which fires on Thursdays per 012 §0.2), if today is Thursday and the Plan or prior session-state indicates /retrospective is queued, defer TIER1_CURATION_DUE by 1 day (set to 0 for this run, will fire on the next /distill invocation). Standalone Thursday /distill runs without retrospective context proceed normally.

Step 1.6: Build language args

Before launching any sub-agent (single-file mode step 2, Step 4 Group 1, Step 6 Group 2 Phase 3, or Step 8 Group 3 Phase 4), call build_language_args() to decide whether to inject narrative-language args into each sub-agent invocation. The function is intentionally trivial — distribution default is English (sub-agent prompts are written in English), so absence of a personal override means no args are injected and the sub-agent's English default takes over naturally. No fallback logic needed on either side.

The top-of-file "Conduct ALL conversation with the user in the language defined by .claude/rules/personal-language.md" instruction governs the orchestrator's (main session's) user-facing utterances; this prologue governs argument injection into sub-agent invocations. They share a trigger file but operate on different surfaces — the user-facing rule has no effect on sub-agent output, which is exactly what this prologue closes.

# build_language_args()
# Returns: inject_args string (or empty if no non-English target is detected).
# Called once per skill invocation, before agent fanout.
#
# Locale detection: presence of personal-language.md is NOT a signal — the
# onboarding skill creates the file for English vaults too, and `rill init
# --lang en` likewise. We pattern-match for any Unicode codepoint in the
# range U+3040-U+30FF, which spans the Hiragana block (U+3040-U+309F) and
# the Katakana block (U+30A0-U+30FF). Both scripts are exclusive to
# Japanese — Chinese and Korean writing systems use Han / Hangul
# respectively and contain neither Hiragana nor Katakana — so a hit here is
# a near-certain ja signal. The stock-ja personal-language.md template
# contains both Hiragana (particles, verb endings) and Katakana (loanwords)
# in its body bullets, so any user-edited derivative that retains even one
# Hiragana or Katakana glyph is detected. Pure-Kanji-only Japanese content
# is the one remaining miss case (Kanji is shared with Chinese, so we cannot
# distinguish), but that style is uncommon for personal-language.md.
# Stock-en and other Latin-script vaults have no such codepoints and fall
# through to the no-injection branch.
#
# Implementation: We use `perl -CSD` (UTF-8 decode on STDIN) with the
# codepoint range above. The earlier `LC_ALL=C grep -qE $'\xe3\x81|...'`
# form relied on bash ANSI-C byte literals, which the default zsh harness
# Claude Code launches via the Bash tool does not interpret as raw bytes —
# detection silently failed under zsh and `output_language` came back empty.
# perl is in PATH on every macOS / Linux distribution that ships Claude
# Code, and Unicode codepoint regexes carry no shell-quoting ambiguity.
#
# Multi-locale detection (mapping all 9 onboarding-supported locales correctly)
# is out of scope for this task and deferred to a separate task. Doing it right
# requires a structured marker (frontmatter or sentinel comment) that bin/rill
# would have to write — and migration of existing personal-language.md files.
# Until that lands, vaults in zh / ko / fr / de / es / pt / it / en receive
# English narrative output (the same behavior as before this skill landed).

output_language=""
if [[ -f .claude/rules/personal-language.md ]] && \
   perl -CSD -e 'while(<>){if(/[\x{3040}-\x{30ff}]/){exit 0}} exit 1' .claude/rules/personal-language.md; then
  output_language="ja"
fi

if [[ -n "$output_language" ]]; then
  # style_guide is hardcoded English. Protocol sentinels listed below MUST stay
  # English literal in sub-agent output — the coordinator string-matches them
  # later (see journal-agent.md / knowledge-agent.md / think-output-agent.md /
  # profile-agent.md / task-extraction.md Language sections, and Step 9's
  # `### Created knowledge files` aggregation). Translating them would break
  # pipeline aggregation, .processed status tracking, and Tier-aware processing.
  style_guide='Write narrative output fields (knowledge note bodies, _organized/ restructured prose, key fact entries, task candidate Title and hint, and Interest Profile additions / updates) in the language specified by output_language. English exceptions (only): (1) tokens inside backticks, (2) proper nouns, (3) ASCII acronyms, (4) any literal sentinel string or fixed enum value documented in this sub-agent prompt'\''s Language section or Output schema — including the section heading `### Created knowledge files`, the sentinels `No tasks` and `No changes to Interest Profile`, status labels (`organized`/`extracted`/`skipped`/`success`/`failed`), Tier enum (`tier1`/`tier2`/`tier3`), type enum (`record`/`insight`/`reference`), all kebab-case slugs, paths, mentions entity IDs, frontmatter field names and values, and task pipe field names (`slug:`/`mentions:`/`source:`/`hint:`/`depends-on:`/`blocks:`) — which must remain verbatim English regardless of output_language because the coordinator string-matches them. Translate all other English (common nouns, adjectives, verb metaphors). When translating, prefer the established target-language term (a word actually used in documents written by native speakers); if none exists, prefer a loanword form in common use; otherwise keep the English term inside backticks with a short parenthetical gloss on first use. Never invent literal calques that do not exist in the target language, and keep one consistent rendering per concept within a document.'
  inject_args="output_language: ${output_language}
style_guide: |
  ${style_guide}"
else
  # No detected non-English target. Sub-agent prompt is in English, so absence
  # of args naturally yields English output — no fallback logic needed here.
  # The top-of-file "use the user's input language if personal-language.md is
  # absent" rule governs the orchestrator's user-facing utterances only (the
  # disambiguation paragraph above states this explicitly). Sub-agent narrative
  # output uses the prompt-language default (English) until the user expresses
  # a persistent preference by running onboarding or `rill init --lang`.
  inject_args=""
fi

When inject_args is non-empty, append it as additional YAML lines to each sub-agent invocation's prompt, alongside the existing shared context block. The style_guide string is hardcoded in English on purpose: the public rillmd/rill repo stays ASCII-only, and the string is itself an English instruction. Broader-locale support (ko, zh, fr, de, es, pt, it) extends the detection branch above without touching the sub-agent prompts or the style_guide content.

Append targets (5 spawn sites in this skill):

  1. Single-File Mode step 2 (_distill/knowledge-agent.md)
  2. Step 4 Group 1 Phase 1a (_distill/journal-agent.md)
  3. Step 4 Group 1 Phase 1b (_distill/think-output-agent.md)
  4. Step 6 Group 2 Phase 3 (_distill/knowledge-agent.md)
  5. Step 8 Group 3 Phase 4 (_distill/profile-agent.md)

Do NOT append to (receivers do not implement language args; out of this task's scope, tracked as follow-up work):

  • Single-File Mode step 4 and Step 5 step 3 (_task/create-agent.md invocations)
  • Step 4 Group 1 Phase 2 (plugins/*/distill.md invocations)

Step 2: Collect Processing Targets

Collect unprocessed files in 2 categories:

  • Root drop zone relocation (runs first): Glob inbox/*.md (root-level Markdown files only, not inside subdirectories). For each match, excluding inbox/CLAUDE.md, move it to inbox/sources/{filename} using git mv when the file is tracked, otherwise mv. This enables users to drop arbitrary Markdown files directly into inbox/ as a generic drop zone; relocated files are then picked up by the Phase 2 sources/ glob below. If no root-level matches exist, skip silently.
  • Refresh queue check: Read knowledge/.refresh-queue. If not empty, display "knowledge/.refresh-queue has N pending refreshes. Use /repair to process them" (not processed by /distill itself)
  • Phase 1a (journal): Glob inbox/journal/*.md → compare with inbox/journal/.processed → unprocessed journals (exclude _organized/ files and .gitkeep)
  • Phase 1b (think-outputs): Glob inbox/think-outputs/*.md → compare with inbox/think-outputs/.processed → unprocessed think-outputs (AI-extracted microfiles structured at write time; exclude .gitkeep. No _organized/ is generated for this category)
  • Phase 2: Glob inbox/{meetings,web-clips,tweets,sources}/*.md → compare with each subdirectory's .processed → unprocessed inbox files (exclude _organized/, .gitkeep, .processed)

※ Workspace distillation is handled by /close in the parent context (ADR-072). Not processed in batch pipeline

Display target counts for all categories. Also display the organized-backlog per Phase 2 subdirectory — files organized in a prior run but not yet knowledge-extracted — via rill processed count inbox/{subdir}/.processed organized (last-wins). This surfaces silent carry-over that the old append-style .processed hid. If the unprocessed counts and the organized-backlog are all 0, display "No unprocessed files" and exit; otherwise proceed (Step 6 Phase 3 consumes the backlog).

Step 3: Plugin Discovery

  1. Read plugins/.enabled to get the list of enabled plugins. If the file does not exist or is empty, skip to Step 4 using plugins/_default-distill.md for all files
  2. For each enabled plugin name, Read plugins/{name}/plugin.md frontmatter. Build source-type → plugin directory name mapping (e.g., meeting → google-meet, tweet → twitter, web-clip → web-clipper)
  3. Resolve prompt path for each Phase 2 file:
    • source-type determination: Infer from inbox subdirectory name (inbox/tweets/ → tweet, inbox/web-clips/ → web-clip, inbox/meetings/ → meeting). If subdirectory name doesn't match mapping, Read the original file's frontmatter source-type
    • Mapping match → plugins/{name}/distill.md
    • No match → plugins/_default-distill.md

Step 4: Group 1 — Parallel Agent Launch

Phase 1/2 are mutually independent. Record all target files as an explicit queue up front (list them, so nothing is silently dropped), then launch one Agent per file in the background (run_in_background: true) — launch the whole queue; do not hand-maintain a fixed-size pool or wait at round boundaries. The harness caps effective concurrency and re-invokes on each completion, so a slow agent no longer blocks a round or gets skipped. Collect results as completions arrive (Step 5).

Phase 2 Pre-processing: Frontmatter Check

For each Phase 2 file, check frontmatter presence before Agent launch. If no frontmatter, auto-infer created and source-type from file creation date and directory name.

Agent Launch

Each agent's prompt composition (template files are Read by the agent itself. Do not Read in parent):

Follow the instructions in .claude/commands/_distill/{template-name}.md to process the following file.
First Read that template file to review instructions, then Read the target file.

Target: {file_path}

Shared context:
### Tag vocabulary (YAML list format. Refer to desc when selecting tags)
{taxonomy_yaml}

### People mapping
{people_mapping}

### Orgs mapping
{orgs_mapping}

### Projects mapping
{projects_mapping}

### Task extraction rules
{task_extraction_rules}
  • Phase 1a (journal): _distill/journal-agent.md (1 file/Agent). Launch via Agent tool with model: "sonnet" — this task is journal organization + atomic knowledge extraction with task-candidate inference, and Sonnet has been validated as production-equivalent to Opus on this workload (Tier 2 LLM-as-judge eval, 2026-04-19: 0/3 DEGRADED-MAJOR, 1/3 EQUIVALENT, 1/3 DIFFERENT-OK, 1/3 DEGRADED-MINOR — the minor case missed one inferred task and one cross-reference, neither blocking; cost reduced ~50% vs Opus). Monitor /distill output 1–2 weeks for task-extraction completeness; revert to Opus if regressions appear. When inject_args (from Step 1.6) is non-empty, append it to each agent's prompt
  • Phase 1b (think-outputs): _distill/think-output-agent.md (1 file/Agent). Launch via Agent tool with model: "sonnet" — same routing rationale as Phase 1a (atomic microfile + Evergreen extraction; no organize step is performed because AI structures the file at write time). Inherit Sonnet eval until think-outputs accumulate enough volume for a separate evaluation. When inject_args (from Step 1.6) is non-empty, append it to each agent's prompt
  • Phase 2: Resolved plugin distill.md (1 file/Agent). Read the plugin's distill.md, extract the ``` block template from ## Agent Prompt section → expand template variables ({file_path}, {taxonomy_yaml}, {people_mapping}, {orgs_mapping}, {projects_mapping}, {task_extraction_rules}) → pass expanded prompt directly to Agent's prompt

Error handling: If an agent reports an error, skip that file and proceed to the next; it is not recorded in .processed, so the next run retries it. The one exception is an agent that reports the exact line Result: skipped (source-unavailable) — its source is permanently gone (e.g. a deleted or private tweet) and a retry cannot succeed, so Step 5 records it as skipped. Agents never write .processed themselves; they run in parallel and the parent owns that file.

Step 5: Group 1 Result Collection

After all agents complete:

  1. Update .processed via rill processed set (do not record files that errored; the CLI enforces one line per file, last-wins — no duplicate rows):
    • journal: rill processed set inbox/journal/.processed <filename> (bare, no status)
    • think-outputs: rill processed set inbox/think-outputs/.processed <filename> (bare; AI structures at write time so no organize step occurs)
    • inbox/* (meetings/web-clips/tweets/sources): rill processed set inbox/{subdir}/.processed <filename> organized
    • inbox/* whose agent reported Result: skipped (source-unavailable): rill processed set inbox/{subdir}/.processed <filename> skipped — no _organized/ file exists and Phase 3 never selects it. Without this the file would be re-queued and fail on every run
  2. Entity ID stripping (deterministic post-processing): Run rill strip-entity-tags <file-paths ...> on created/updated knowledge/notes/ (ADR-046 D46-2)
  3. Aggregate task candidates from all Phase 1 + Phase 2 agents. For each candidate, launch _task/create-agent.md as a sub-agent in mode=extract (launch all in the background, run_in_background: true, harness-capped concurrency, model: "sonnet" — see the Sonnet-routing rationale on the single-file-mode invocation above; same eval applies). Pass the candidate pipe line, the source_path already recorded in it, and the shared context (taxonomy_yaml, people/orgs/projects mappings). The sub-agent handles duplicate checking, substance-rule-compliant body writing, and file creation via rill mkfile tasks --field 'status=draft' ... (ADR-069). Legacy parent-side parsing of | background: / | context: fields and Title::path conversion is no longer performed here — substance writing is owned by the sub-agent per .claude/rules/rill-tasks.md
  4. If new tags are reported, append to taxonomy.md (verify no conflict with deprecated tags)

Step 6: Group 2 — Parallel Agent Launch

Phase 2.5 and Phase 3 are mutually independent, so execute in parallel.

  • Phase 2.5: Entity Auto-extraction (execute directly in parent context):
    1. Read participants: and tags: from inbox/*/_organized/ files processed in Group 1
    2. String-match each participant name against People mapping name/aliases (mapping is already loaded in context from Step 1. No Grep needed for known entities)
    3. Only Grep knowledge/people/ for participants not found in mapping
    4. Participants not found → Auto-create new Person entity (minimal frontmatter + short description)
    5. String-match organizations from body/participants against Orgs mapping name/aliases (no Grep needed for known orgs)
    6. Orgs not found in mapping → Grep knowledge/orgs/ → if not found, auto-create new Org entity (id: kebab-case, aliases: name variants, relationship: context-inferred)
    7. If corresponding people/ company field is a string, update to orgs/ id
    8. Keep created entity IDs consistent with taxonomy.md tags
    9. Report creation results in summary
  • Phase 3: Knowledge Extraction (_distill/knowledge-agent.md, launch Agent per organized file):
    1. Identify candidate files with rill processed list inbox/{subdir}/.processed --status organized (last-wins: only files whose latest .processed line is :organized; a file already extracted is never re-selected even if a stale :organized line lingers from the old append bug)
    2. If no candidates, display "No knowledge extraction candidates" and skip
    3. Launch Agent per file with model: "sonnet" (launch all in the background, run_in_background: true, harness-capped concurrency) — knowledge extraction's defining behavior is the Evergreen check (merge/skip/create-new judgment), and Sonnet has been validated as production-equivalent on this dimension (Tier 2 LLM-as-judge eval, 2026-04-19: 3/3 Evergreen judgments agreed with Opus baseline; 0/3 DEGRADED-MAJOR; 1/3 EQUIVALENT, 1/3 DIFFERENT-OK, 1/3 DEGRADED-MINOR — the minor case had thinner body prose but correct Evergreen call; cost reduced ~49% vs Opus). Monitor /distill output 1–2 weeks for note-body richness and speculative content; revert to Opus if regressions appear.
    4. Inject shared context (taxonomy_yaml, people/orgs/projects mappings, tier_assignment dict from Step 1). The tier_assignment dict is required for _distill/knowledge-agent.md Tier-Aware Processing (artifact 013 §6.1). When inject_args (from Step 1.6) is non-empty, append it to each agent's prompt alongside the shared context

Step 7: Group 2 Result Collection

  1. Run rill strip-entity-tags on knowledge/notes/ created in Phase 3
  2. Mark each extracted file via rill processed set inbox/{subdir}/.processed <filename> extracted — this rewrites the line in place, so the organized → extracted transition stays one line per file (no duplicate row). Leave errored files as-is (still organized, so the next run retries extraction), and never touch a skipped line
  3. Append new tags to taxonomy.md

Step 7.5: Tier 1 curation review (NEW, conditional)

This step runs only when TIER1_CURATION_DUE=1 from Step 1.5 (artifact 013 §4 + 015 §4). Otherwise, skip silently and proceed to Step 8.

For each entity in the Tier dict with tier_assignment == tier1:

  1. Resolve the entity file path from the dict key. Keys are already typed ({type}/{slug} e.g. people/jane-smith, projects/phoenix), so the file path is knowledge/{type}/{slug}.md for people/orgs and projects/{slug}/_project.md for projects (ADR-080). Read that file and count ## Key Facts entries
  2. Skip the entity unless both trigger conditions hold:
    • Key Facts count ≥ 30 (artifact 013 §4.1 condition b — deliberately set higher than the ~20 guideline in knowledge/{people,projects}/CLAUDE.md because that guideline is not actively enforced; 30 catches the empirically-observed overfilled cases like projects/rill.md with 50+ facts. Revising the 20 guideline itself is out of scope for this phase per 013 §4.1)
    • At least 5 new fact entries added in the past 4 weeks (detect via (YYYY-MM) date prefixes in fact lines, or git log --since=4.weeks --follow {path} line additions if blame is preferred)
  3. For each entity that passes both conditions, emit a curation review block.

Generate reports/distill/tier1-curation-{YYYY-MM-DD}.md with one section per flagged entity. rill mkfile reports/distill ignores --slug and always writes reports/distill/{YYYY-MM-DD}.md (bin/rill cmd_mkfile's generic reports/* branch), so get the correct created frontmatter that way (LLMs must never write created by hand — ADR-060) and rename to the slugged filename, the same pattern /retrospective uses for reports/retrospective/{period_id}.md:

mkfile_out="$(rill mkfile reports/distill --type distill-curation --field "period={YYYY-MM-DD}")"
mv "$mkfile_out" "reports/distill/tier1-curation-{YYYY-MM-DD}.md"

Then Edit the body into this format:

# Tier 1 Key Fact Curation Review

## {type}/{id} — current {N} facts, guideline 20

### Deletion candidates (old / duplicate / low-importance)

- [ ] **{date prefix} {fact text}** — reason: {old | duplicate of #M | low-importance single incident}

### Merge candidates

- [ ] {fact #X} + {fact #Y} = "{merged interpretation}" — combinable into one entry

(repeat per entity)

## How to apply

- Mark checkboxes `[x]` for the deletions/merges you approve
- Run `/distill --apply-curation reports/distill/tier1-curation-{date}.md` (Phase 2 future flag; for now, manually edit the entity file)
- Unchecked items will be re-proposed at the next monthly cadence

The LLM picks deletion / merge candidates per artifact 013 §4.3 heuristics:

  1. Old: has (YYYY-MM) prefix, ≥ 6 months ago, and a later fact on the same theme supersedes it
  2. Duplicate: two existing facts express semantically near-identical content (LLM judgment, not embedding)
  3. Low-importance: external references / single incidents with no downstream impact on workspaces or decisions

After the review file is written (or the iteration completes with zero flagged entities), update the state file:

mkdir -p .claude/state
cat > .claude/state/distill-tier1-curation.json <<EOF
{
  "skill": "distill-tier1-curation",
  "last_curation_at": "$(date -Iseconds)",
  "last_curation_file": "reports/distill/tier1-curation-$(date -I).md",
  "entities_flagged_last_run": [...]
}
EOF

Important: this step writes a review file only — no auto-delete, no auto-merge (artifact 013 §4.2 / §1.1 design principle 4). The --apply-curation flag is a Phase 2 deliverable.

Step 8: Group 3

  • Phase 4: Update Interest Profile with _distill/profile-agent.md. Launch via Agent tool with model: "haiku" — this task is conservative metadata maintenance (add/skip judgments against an existing profile) and Haiku has been validated as quality-equivalent to Opus on this workload (3/3 PASS in Tier 1 routing eval, 2026-04-19). Inject the following summary into prompt:
    Follow the instructions in .claude/commands/_distill/profile-agent.md to update the Interest Profile.
    First Read that template file to review instructions.
    
    ## Current /distill Processing Results Summary
    
    ### Newly created knowledge/notes/
    {list of filenames and tags from Phase 1-3}
    
    ### Newly created/updated projects/
    {updated projects/ filenames and change content}
    
    ### Extracted tasks
    {list of approved tasks}
    
    ### Newly created entities (people/, orgs/)
    {list of entities created in Phase 2.5}
    When inject_args (from Step 1.6) is non-empty, append it to the agent's prompt alongside the processing-results summary. Skip if 0 files were processed in Phase 1-3.
  • Phase 5: Read plugins/.enabled. For each enabled plugin, check if plugins/{name}/hooks/post-distill.md exists. If .enabled does not exist or is empty, skip Phase 5. For each found hook, launch Agent. Pass the following context:
    • Created file list: File paths of _organized/, knowledge/notes/, knowledge/people/, knowledge/orgs/ created in Phase 1-3
    • mentions mapping: person-id / org-id list extracted from mentions in created knowledge/notes/
    • Added tasks: List of approved new tasks
    • Plugin path: plugins/{plugin-name}/
    • Failures are non-fatal: Log and skip errors during hook execution

Step 9: Pages Pending Update (the "new candidates" push)

After all Phases complete, before the final summary:

  1. Aggregate newly created knowledge/notes/ paths from:
    • Phase 1 journal-agent outputs → ### Created knowledge files section
    • Phase 3 knowledge-agent outputs → ### Created knowledge files section
    • Plugin distill.md agent outputs (if the plugin follows the same ### Created knowledge files convention)
  2. Exclude refresh-agent output (refresh-agent is not part of /distill, but this guard exists so future integrations don't accidentally feed Evergreen updates into pending)
  3. If the aggregated list is empty, skip this step
  4. Write the aggregated paths to a temporary sources file (one per line, absolute or repo-relative paths both accepted by the CLI), then invoke:
    tmp=$(mktemp)
    printf '%s\n' "${created_files[@]}" > "$tmp"
    rill pages-pending-update --sources-file "$tmp" --origin distill
    rm -f "$tmp"
  5. The CLI matches each new file's mentions (Layer 2) or tags (Layer 3 fallback, only for pages without mentions) against all pages/*.md and upserts entries into pages/.pending
  6. Do NOT pass --force blindly. If the CLI prints ⚠ bulk update detected, the aggregated list is likely contaminated with Evergreen updates or a migration slipped in — investigate rather than override

Design essence: pages carried no mentions at all when matching was first designed, so the matcher is layered — mentions intersection first, tags fallback only for pages without mentions — and a bulk-update threshold keeps migrations / mass refreshes from flooding pages/.pending with noise a human would have to ack away.

Step 10: Summary + Task Approval

After all Phases complete, display the following summary:

  • Phase 1: Processed / skipped count, created file list
  • Phase 2: Organized / skipped count, created file list. List each file recorded as skipped (source unavailable) by name with its reason, separately from files that errored and will be retried — the user needs to know a source was written off
  • Phase 2.5: Entity creation / skip count
  • Phase 3: Extraction / skip count, created knowledge list
  • Phase 4: Interest Profile update content (only if changes occurred)
  • Phase 5: Hook execution results (plugin name, result summary)
  • Task candidate list (Phase 1-2 total) — created as ticket files (/briefing will highlight new tasks)

Step 11: /pulse refresh (NEW)

After Step 10 (Summary) completes, invoke /pulse via the harness's Skill tool to refresh knowledge/self/current-state.md. This Auto-chain keeps the snapshot fresh after each distillation cycle (015 §2.1):

Skill(name: "pulse", args: "")

The invocation is synchronous. /pulse handles its own 12h cooldown — if recently run it no-ops silently. Do not parse, display, or summarize /pulse's output in /distill's summary — discard the return value.

Non-recursion guarantee (009 §1.5): /distill's path scoping already excludes knowledge/self/, and /pulse never invokes /distill, so this chain is structurally one-way.

If the /pulse invocation fails for any reason, log a 1-line warning to stdout and continue — /pulse refresh failure is not fatal to /distill.

Rules

  • Never modify inbox/ original files (read-only. Exception: auto-adding frontmatter is allowed)
  • .processed is written and read via rill processed (never hand-appended): set rewrites one line per file (last-wins), count / list --status read last-wins, normalize collapses any legacy duplicate rows. This keeps the organized → extracted transition to a single line and prevents an already-extracted file from being re-selected by a stale :organized line
  • inbox/journal/.processed records filenames only (no path prefix. e.g., 2026-02-13-1921.md); set with no status preserves this bare form
  • inbox/{subdir}/.processed uses filename:status format (e.g., 2026-02-16-meeting.md:organized)
  • Agent prompt templates (.claude/commands/_distill/) are Read by agents themselves (do not Read in parent context). Exception: task-extraction.md is Read by parent and injected as shared context data for child agents so they can return task candidates; actual ticket writing is delegated to the _task/create-agent.md sub-agent invoked by the orchestrator
  • Plugin distill.md is Read by parent, template variables expanded, and injected inline into prompt
  • Template variable names are unified: {taxonomy_yaml}, {people_mapping}, {orgs_mapping}, {projects_mapping}, {task_extraction_rules}, {file_path}
  • Error handling: If an agent returns an error, skip that file and do not record it in .processed (no rill processed set call for it), so the next run retries it. Exception: an agent reporting Result: skipped (source-unavailable) is recorded as skipped in Step 5, because its source is permanently gone and retrying can never succeed. Include both counts in the summary
  • zsh compatibility: Refer to CLAUDE.md rule 26

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.