keep prompt

Render an agent prompt with injected context from the store.

Usage

keep prompt --list                        # List available prompts
keep prompt reflect                       # Render the reflect prompt
keep prompt reflect "auth flow"           # With search context
keep prompt reflect --id %abc123          # Context from specific item
keep prompt reflect --since P7D           # Recent context only
keep prompt reflect --tag project=myapp   # Scoped to project

Options

OptionDescription
--list, -lList available agent prompts
--id IDItem ID for {get} context (default: now)
--tag, -t KEY=VALUEFilter search context by tag (repeatable)
--since DURATIONOnly items updated since (ISO duration or date)
--until DURATIONOnly items updated before (ISO duration or date)
--deep, -DFollow tags/edges from results to discover related items
--scope, -S GLOBConstrain search results to IDs matching glob
--tokens NToken budget for {find} context rendering (default: template default)

Template placeholders

Prompt docs may contain placeholders that are expanded at render time:

PlaceholderExpands to
{get}Full context for --id target (default: now) from the prompt's state-doc bindings
{find}Search results for the text argument from the prompt's state-doc bindings
{find:deep}Deep search — follows edges from results to discover related items
{find:deep:N}Deep search with explicit token budget N
{text}Raw query text passed as the text argument
{since}The --since filter value (ISO duration or date), empty if not given
{until}The --until filter value (ISO duration or date), empty if not given
{binding_name}Flow binding — see State-doc backed prompts below
{{include:NAME}}Literal include of another prompt doc's ## Prompt body — resolves to .prompt/NAME (e.g. {{include:agent/system}})

When no text argument is given, {find} and {text} expand to empty. When no --id is given, {get} shows the now document context.

Prompt includes

{{include:NAME}} is expanded before any other placeholders and lets one prompt doc wrap or extend another. The directive is bounded to the prompt namespace — NAME resolves to .prompt/{NAME} — so included content can only come from other prompt docs. Cycles and missing targets raise an error rather than silently rendering empty. The character set disallows path escapes (no .., no dots).

A typical use is a host-specific wrapper that adds framing around a generic prompt body:

## Prompt

══════════════════════════════════════════════
KEEP — REFLECTIVE MEMORY
══════════════════════════════════════════════

Host-specific orientation here…

{{include:agent/system}}

══════════════════════════════════════════════

State-doc backed prompts

A prompt doc can reference a state doc via a state tag. When present, the state doc flow runs and its bindings become {binding_name} placeholders in the template. This allows custom retrieval pipelines to be composed into prompts.

Dynamic prompts are state-doc backed: a prompt that uses {get} or {find} but has no state tag is treated as invalid instead of falling back to a built-in Python retrieval path.

Example

Given the .state/get state doc (with its openclaw fragment) that produces bindings similar, meta, edges, session:

keep put "$(cat <<'EOF'
## Prompt
{similar}
{session}

Question: {text}
Answer precisely using the context above.
EOF
)" --id .prompt/agent/my-query -t state=get -t context=prompt

Now keep prompt my-query "auth flow" runs the get state doc and renders its bindings into the template.

Each binding is rendered by type:

The token budget is distributed across bindings. Bindings not referenced in the template are ignored.

Prompt docs

Agent prompts live in the store as .prompt/agent/* system documents. They use the same ## Prompt section format as other keep prompt docs, but contain agent-facing instructions rather than LLM system prompts.

Bundled prompts, loaded on first use:

PromptIDPurpose
reflect.prompt/agent/reflectFull structured reflection practice
conversation.prompt/agent/conversationConversation analysis — commitments, breakdowns, moods
query.prompt/agent/queryAnswer questions using retrieved memory context
session-start.prompt/agent/session-startContext injection at session start
subagent-start.prompt/agent/subagent-startContext injection for subagent initialization
system.prompt/agent/systemGeneric system-prompt orientation for agents using keep as a memory provider
system-hermes.prompt/agent/system-hermesHermes-specific system-prompt wrapper (frames system with layered-memory division of labor)

Viewing and editing

keep get .prompt/agent/reflect            # View the prompt doc

Prompt docs are editable — they version like any other store document. User edits are preserved across upgrades (content-hash detection).

MCP Prompt exposure

Selected agent prompt docs can also be exposed as MCP Prompts. This is opt-in via the prompt doc's mcp_prompt tag, which lists the advertised optional argument names in order:

tags:
  context: prompt
  state: get
  mcp_prompt: text,id,since,token_budget

Supported MCP Prompt argument names are:

The broader keep_prompt tool remains available for the full option set, including until, tags, deep, and scope.

keep reflect

keep reflect is an alias for keep prompt reflect. It accepts the same text argument and --id option:

keep reflect                              # Same as: keep prompt reflect
keep reflect "auth flow"                  # Same as: keep prompt reflect "auth flow"
keep reflect --id %abc123                 # Same as: keep prompt reflect --id %abc123

See Also