Repository navigation
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Problem
Keen has no way to automatically react to tool or session events. Users must repeatedly ask the model to run formatters, tests, or policy checks by hand.
Proposal
Add declarative hooks that run external shell commands on lifecycle events.
MVP events
before_tool/after_toolafter_writeturn_endsession_end
Example hook
hooks:
- event: after_write
pattern: "*.go"
command: ["gofmt", "-w", "{{file}}"]
timeout: 30s
on_error: fail # warn | ignore
stdout: capture Requirements
- External commands only; no in-process plugins.
- Templating for
{{file}},{{tool}},{{session_id}}, etc. - Timeout and output bounds.
- Configurable fail-open vs fail-closed behavior.
before_toolhooks can block a tool call with a reason.- Commands are subject to the existing permission system.
- Deduplicate
(event, file)per turn; avoid recursive hooks. - Add
/hooks listand/hooks dry-runfor inspection.
Use cases to document
- Auto-format on save (
gofmt,prettier,rustfmt,black). - Run focused tests after relevant file changes.
- Reject writes that fail a policy check.
- Regenerate artifacts after source changes.
Alternatives considered
- Prompt engineering: unreliable.
- Built-in formatters/test runners: too much surface.
- MCP file-watching hooks: cannot react to Keen-internal events or block tool calls.
Context
- Flagged during OMP analysis as a high-value workflow feature.
- Currently on the Tier 3 roadmap in `ROADMAP.md
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Activity