Customize OpenCode's /compact with per-invocation instructions.
/compact keep only necessary information
Normally /compact (alias /summarize) accepts no arguments and summarizes the
session with a fixed prompt. This plugin lets you steer the summary every time
you compact.
Add it to your OpenCode config (~/.config/opencode/opencode.json or a project
opencode.json).
From GitHub:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["github:cesumilo/opencode-compact-instructions"]
}From npm (if published):
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-compact-instructions"]
}Restart OpenCode after changing the config.
/compact
/compact keep only necessary information
/compact focus on the API design and open questions
What happens:
- The plugin registers a
compactcommand that overrides the built-in one so it accepts arguments. - Running it triggers the real compaction (
session.summarize). - Your instructions are appended to the compaction prompt.
- The model used for compaction is taken from the session's most recent message.
- OpenCode's command pipeline always sends a prompt after the command hook, so a hidden synthetic turn acknowledges the compaction ("Session compacted — ready to continue.").
- If you already define your own
compactcommand, this plugin leaves it alone.
bun install
bunx tsc --noEmitMIT