Skip to main content
Trellis can attach specs to code paths and deliver the matching rules when an agent touches a file. This keeps the prompt small while putting the relevant rules close to the edit they govern.

Declare which paths a spec governs

Add a paths list to the spec’s YAML frontmatter. Paths are relative to the repository root.
The matcher supports:
  • * within one path segment
  • ** across path segments
  • ? for one character
  • a trailing / as shorthand for everything below that directory
Specs without paths frontmatter keep their existing behavior. They are not loaded automatically.

What the agent receives

For each matching spec, Trellis chooses one of three deliveries: The refresh window is fixed. Silent touches do not extend it, so continuous editing still receives a later reminder. When several specs match one file, narrower path patterns are considered before broad patterns. If the event budget cannot hold every full body, remaining matches become an index of spec paths instead of disappearing.

Platform behavior

Why Codex blocks the first patch once

Codex does not require a file read before an edit. When a patch first matches a spec, the hook returns the full rules and denies that patch once:
Only a newly delivered full spec blocks the patch. A short refresh ticket does not block, and an unchanged spec inside the refresh window produces no output. This is a context-delivery handshake, not a policy rejection.

Configure the budget and refresh window

The defaults fit the host context limits and require no configuration:
Truncated bodies include a notice with the full spec path so the agent can read the source file directly.

Inspect matches manually

Use pull mode to check which specs govern a path without loading their bodies:
Add --json for structured output:
An empty match is valid and returns no governing specs.

State, reset, and failure behavior

Delivery state is stored outside the repository under ~/.trellis/spec-inject/. Parent and sub-agent histories are separate. SessionStart(source=clear|compact) records a reset marker shared by that session, so rules removed by compaction are delivered again. The hook does not parse Claude Code or Codex transcript contents. Transcript formats are host internals and are not part of this contract. Matching and state failures are fail-open: malformed frontmatter, missing paths, unreadable state, or an internal hook error must not break the host tool call. The only intentional block is the first Codex patch that has just received a full governing spec.