Repository navigation
Feature: Commands
Thatch's /thatch/* commands come in two families:
-
Actions (
defrag,extract,hygiene,reflect) — user-invoked wrappers around behaviors the nudges otherwise run on their own schedule. -
Wrap-ups (
compact,exit) — greenlight-gated pre-compaction and pre-exit checklists. opencode only: the greenlight check needs the plugin'scommand.execute.beforearming and TUI control routes.
User-facing guide: ../../user/commands.md.
Action bodies are prompt cores: constants in src/prompts.ts
(defragCore, hygieneCore, reflectCore, extractionCore) that hold the
host-agnostic instruction text for one behavior. The nudge envelopes wrap
the same cores with escalation tiers and the stop-and-wait ending; command
and prompt renderers wrap them with frontmatter and a user-message section.
The point is drift-proofing: a wording change lands in the nudge and the
command at once, and a test asserts each rendered file contains its core
verbatim.
The stop-and-wait ending ("do not advance pending work on this nudge's
account") is nudge-only by design. A /thatch command IS user input, so
the command envelope must not inherit it.
Cores that name memory tools take a ToolNamer because spellings differ
per host: thatch_find_duplicates on opencode, mcp__thatch__find_duplicates
on MCP hosts. Each host's renderer passes its own namer
(opencodeToolName / mcpToolName).
src/commands.ts is the single registry:
-
actionDefs(tool)returns the action set with bodies rendered for one host. Actions needing plugin-only capabilities are markedopencodeOnly(extract: needs session identity viaget_session_info). -
opencodeCommandDefs()= wrap-up templates + all actions. Synced by the plugin at init into$XDG_CONFIG_HOME/opencode/command/thatch/(installOpencodeCommands), content-compare, self-healing. -
claudeCommandDefs()= actions minusopencodeOnly. Synced bythatch setup --claude(installClaudeCommands) into<claudeDir>/commands/thatch/, reported in the setup output. There is no plugin on this host to sync on load, so setup is the sync point. - MCP prompts:
compilePrompts()insrc/mcp.tsexposes the same non-opencodeOnly actions throughprompts/list/prompts/get, which Cursor surfaces as slash commands. The optionalfocusargument is appended to the body as aFocus:line, standing in for the file commands'$ARGUMENTS.
A parity-guard test asserts the three sets are the same actions minus the
documented exclusions: opencode = Claude Code set + compact, exit,
extract; MCP prompts = Claude Code's set.
/thatch/extract runs the extraction flow on demand: learn the session ID
from thatch_get_session_info, dispatch the extractor sub-agent with an
explicit session_id, acknowledge with thatch_extraction_done. The
explicit ID matters because the sub-agent's session differs from the
parent's — the same reason the extraction nudge passes it.
get_extraction_payload accepts an omitted session_id: on the opencode
path the wrapper supplies the invoking session's HostToolContext.sessionID.
The zod arg shape is shared between hosts, so optionality cannot be
per-host at the schema level; on MCP hosts (no session context) an omitted
session_id returns a clear "pass the parent's session_id" error. The rule
the model applies, stated in the arg descriptions and the dev docs:
Omit
session_idwhen acting on the session you are running in. Pass the parent session'ssession_idwhen running inside a sub-agent dispatched to process another session's extraction queue.
User
- Guide: Behavior Engine
- Guide: Cli
- Guide: Code Review
- Guide: Commands
- Guide: Cross Session Chat
- Guide: Deduplication
- Guide: Default Behaviors
- Guide: Extraction
- Guide: Hygiene
- Guide: Memory
- Guide: Notifications
- Guide: Prediction Engine
- Guide: Overview
- Guide: Setup
- Guide: Skills
- Guide: Watchers
Developer
Dev Feature Guides
- Feature: Behavior Engine
- Feature: Cicd
- Feature: Cli
- Feature: Commands
- Feature: Compaction Recovery
- Feature: Cross Session Chat
- Feature: Database
- Feature: Deduplication
- Feature: Extraction
- Feature: Hygiene
- Feature: Memory Store
- Feature: Multi Host
- Feature: Notifications
- Feature: Nudge Pipeline
- Feature: Opencode Plugin
- Feature: Prediction Engine
- Feature: Qa System
- Feature: Overview
- Feature: Repo Identity
- Feature: Session Lifecycle
- Feature: Setup
- Feature: Sideband
- Feature: Watchers