Skip to content
Agent Orchestration
Command

/prime

Load relevant knowledge base facts into context before starting work

From plugin
metaswarm
43216 skills23 agents16 commands2 hooks
$ npx -y skills add dsifry/metaswarm --agent claude-code

Command definition

prime.md
description: Load relevant knowledge base facts into context before starting work

Prime (metaswarm knowledge priming)

**CRITICAL**: Run this command at the START of any investigation, planning, or implementation work to load relevant knowledge into your context.

When to Use

  • Starting work on a GitHub Issue
  • Beginning investigation/research
  • Before writing a plan
  • Before implementing changes
  • When switching to a new area of the codebase

How It Works

`/prime` reads metaswarm's knowledge base, the JSONL fact files in `.beads/knowledge/` (the project's own learnings) and, in the metaswarm repo, the shipped examples in `knowledge/`, and filters it with `jq` down to the facts relevant to your current work, so you:

1. Follow established patterns and rules 2. Avoid known gotchas and pitfalls 3. Make decisions aligned with architectural choices 4. Don't repeat mistakes that have been learned from

`/prime` filters on three things, any combination of which can be given as arguments (e.g. `/prime auth src/api/auth/ implementation`):

| Filter | Matches against | |---|---| | **Keyword** (topic, e.g. `auth`) | `.fact` and `.tags` (case-insensitive) | | **File** (path or path fragment you will touch) | `.affectedFiles` | | **Work type** (planning, implementation, review, debugging, research, release) | `.type` (e.g. `gotcha`, `pattern`, `decision`, `api_behavior`) |

The bd workflow reference is separate: if bd is installed, plain `bd prime` prints bd's own workflow reference and any `bd remember` memories. It has no filters and never reads `.beads/knowledge/`, so use `/prime` for the knowledge base.

Usage

The knowledge files may start with `#` comment lines (the shipped `knowledge/*.jsonl` do), so strip them with `grep -hv '^#'` before handing the lines to `jq`. Set `KB` to the store you want to search:

KB=.beads/knowledge      # project knowledge (or: KB=knowledge for the shipped examples)

Prime for Keywords

When working on a specific topic (`K` is a case-insensitive regex):

K="auth"
grep -hv '^#' "$KB"/*.jsonl | jq -r --arg k "$K" 'select((.fact | test($k; "i")) or ((.tags // []) | any(test($k; "i")))) | .fact + (if .recommendation then "\n  -> " + .recommendation else "" end)'

Prime for Files

When working on specific files (`F` is a path or path fragment):

F="src/api/auth/"
grep -hv '^#' "$KB"/*.jsonl | jq -r --arg f "$F" 'select((.affectedFiles // []) | any(contains($f))) | .fact + (if .recommendation then "\n  -> " + .recommendation else "" end)'

Prime for Work Type

Pick the fact types that matter for the work you are doing:

| Work type | Fact types to load | |---|---| | planning | `decision`, `pattern`, `gotcha`, `dependency`, `security` | | implementation | `pattern`, `gotcha`, `api_behavior`, `dependency`, `performance`, `security` | | review | `pattern`, `gotcha`, `decision`, `security`, `performance` | | debugging | `gotcha`, `api_behavior`, `code_quirk`, `dependency`, `performance` | | research | `decision`, `pattern`, `gotcha`, `api_behavior`, `code_quirk`, `dependency`, `performance`, `security` (all types) | | release | `decision`, `pattern`, `gotcha`, `dependency`, `security` |

T="pattern|gotcha|api_behavior|dependency|performance|security"   # implementation
grep -hv '^#' "$KB"/*.jsonl | jq -r --arg t "$T" 'select(.type | test("^(" + $t + ")$")) | "[\(.type)] " + .fact + (if .recommendation then "\n  -> " + .recommendation else "" end)'

Combined

Filters compose with `and` inside one `select`:

grep -hv '^#' "$KB"/*.jsonl | jq -r --arg k "auth" --arg f "src/api/" --arg t "gotcha|pattern" '
  select(((.fact | test($k; "i")) or ((.tags // []) | any(test($k; "i"))))
         and ((.affectedFiles // []) | any(contains($f)))
         and (.type | test("^(" + $t + ")$")))
  | "[\(.type)] \(.fact) -> \(.recommendation // "")"'

Prime for Context Recovery

When resuming after context compaction or in a new session, see "Context Recovery" below: read the persisted plan and context files directly, then prime for the work you are resuming.

What Gets Loaded

1. MUST FOLLOW (Critical Rules)

Non-negotiable rules containing NEVER/ALWAYS/MUST:

  • "NEVER use `as any` type casting"
  • "ALWAYS use centralized AI config"
  • Security-critical patterns

2. GOTCHAS (Common Pitfalls)

Known issues to avoid:

  • "Truthy check fails for explicit zero values - use !== undefined"
  • API behavior quirks

3. PATTERNS (Best Practices)

Established patterns in this codebase:

  • "Use mock factories from test utilities"
  • "Services should follow TDD (Red-Green-Refactor)"

4. DECISIONS (Architectural Choices)

Team/architectural decisions:

  • "State management uses Zustand + TanStack Query"
  • "AI providers implement Strategy Pattern"

5. API BEHAVIORS

External API quirks:

  • "Prisma findMany returns [] not null"

Integration Points

In Planning Phase

Before writing a plan, run `/prime` for planning work on the task's keywords.

In Implementation Phase

Before writing code, run `/prime` for implementation work touching the files you will change.

In Review Phase

Before reviewing code, run `/prime` for review work touching the changed files.

Manual Knowledge Check

If you need to check for specific knowledge:

# Search for a specific topic
grep -hv '^#' .beads/knowledge/*.jsonl | jq -r 'select(.fact | test("authentication"; "i")) | .fact'

# Get all gotchas
grep -hv '^#' .beads/knowledge/gotchas.jsonl | jq -r '.fact'

# Get all patterns
grep -hv '^#' .beads/knowledge/patterns.jsonl | jq -r '.fact'

Output Format

Present the filtered facts grouped like this:

# Relevant Knowledge Base Facts

_25 facts loaded for this context_

## MUST FOLLOW (Critical Rules)

These are non-negotiable rules:

- **[pattern]** NEVER use `as any` type casting...
- **[security]** Always validate JWT tokens server-side...

## GOTCHAS (Common Pitfalls)
Read more
@dsifry
Ships withmetaswarm

A self-improving multi-agent orchestration framework for Claude Code, Gemini CLI, and Codex CLI.

43214 skills23 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
432
Star history of dsifry/metaswarm on GitHub, a chart by star-history.com

Other commands on metaswarm.

brainstorm

brainstorm

Command

Refine an idea into a design with brainstorming, then run the design review gate for project-sized designs

@dsifry@dsifryInstall Command
create-issue

create-issue

Command

Create a well-structured GitHub issue with acceptance criteria and agent instructions

@dsifry@dsifryInstall Command
handoff

handoff

Command

Analyze the session and write a self-contained handoff document so a fresh agent can resume the work — outputs a single "Read…

@dsifry@dsifryInstall Command
pr-shepherd

pr-shepherd

Command

Monitor a PR through to merge - handles CI failures, reviews, and thread resolution

@dsifry@dsifryInstall Command

More commands from other plugins.

COMMAND_COMPLIANCE_REPORT

COMMAND_COMPLIANCE_REP…

Command

Reviewed all command files in `.claude/commands/analysis/` directory to ensure proper usage of: - `mcp__claude-flow__*` tools…

@ruvnet@ruvnetInstall Command
ask

ask

Command

This compatibility command keeps `/oh-my-claudecode:ask` available without loading the full `ask` skill description in every…

@yeachan-heo@yeachan-heoInstall Command