-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Lifecycle hooks #549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Lifecycle hooks #549
Conversation
- Replace config-based hooks with convention-based discovery from openspec/hooks/ - Add Decision 5 for integration distribution model - Update spec requirements for directory scanning and file naming convention - Revise tasks for hook discovery implementation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughIntroduces a comprehensive design for injectable lifecycle hooks in OpenSpec, enabling custom Markdown instructions to be injected at lifecycle phase boundaries (proposal, apply, archive) through convention-based discovery from namespaced integration folders without modifying core code. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review CompleteYour review story is ready! Comment !reviewfast on this PR to re-generate the story. |
Greptile SummaryThis PR introduces a well-designed lifecycle hooks system that enables extensible integrations (Linear, Jira, Slack, etc.) through convention-based markdown instruction files. The proposal follows OpenSpec's spec-driven development workflow with comprehensive documentation. Key Changes:
Strengths:
Issue Found:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant CLI as OpenSpec CLI
participant Templates as slash-command-templates.ts
participant Hooks as hooks.ts (new)
participant FS as File System
User->>CLI: openspec instructions proposal --change add-feature
CLI->>Templates: getSlashCommandBody('proposal', projectRoot)
Templates->>Hooks: discoverHooks(projectRoot, 'proposal')
Hooks->>FS: Read openspec/hooks/*/
FS-->>Hooks: [linear/, slack/, custom/]
loop For each integration folder
Hooks->>FS: Read before-proposal.md
FS-->>Hooks: Hook content (<50KB)
Hooks->>FS: Read after-proposal.md
FS-->>Hooks: Hook content (<50KB)
end
Hooks->>Hooks: Concatenate by alphabetical order
Hooks-->>Templates: {before: [...], after: [...]}
Templates->>Templates: Build instruction template
Note over Templates: 1. Guardrails<br/>2. Inject before hooks<br/>3. Steps<br/>4. References<br/>5. Inject after hooks
Templates-->>CLI: Complete instructions with hooks
CLI-->>User: Display enriched instructions
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 files reviewed, 1 comment
| ### Modified Capabilities | ||
| - `slash-commands` - Extend template generation to discover and inject hooks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Missing delta spec for slash-commands capability modification - proposal claims to modify slash-commands capability but no delta spec exists at changes/add-lifecycle-hooks/specs/slash-commands/spec.md
Per AGENTS.md line 196: "If multiple capabilities are affected, create multiple delta files under changes/[change-id]/specs/<capability>/spec.md—one per capability."
Options:
- Add a delta spec at
specs/slash-commands/spec.mdwith MODIFIED requirements - If
slash-commandsisn't an existing capability, remove this line or clarify that template generation changes don't require a separate capability spec
Prompt To Fix With AI
This is a comment left during a code review.
Path: openspec/changes/add-lifecycle-hooks/proposal.md
Line: 22:23
Comment:
**logic:** Missing delta spec for `slash-commands` capability modification - proposal claims to modify `slash-commands` capability but no delta spec exists at `changes/add-lifecycle-hooks/specs/slash-commands/spec.md`
Per AGENTS.md line 196: "If multiple capabilities are affected, create multiple delta files under `changes/[change-id]/specs/<capability>/spec.md`—one per capability."
Options:
1. Add a delta spec at `specs/slash-commands/spec.md` with MODIFIED requirements
2. If `slash-commands` isn't an existing capability, remove this line or clarify that template generation changes don't require a separate capability spec
How can I resolve this? If you propose a fix, please make it concise.
Add Lifecycle Hooks for Extensible Integrations
Summary
This PR introduces a lifecycle hooks system that enables custom integrations (Linear, Jira, Slack, etc.) without modifying OpenSpec's core code. Hooks are markdown instruction files that get injected into proposal, apply, and archive phases.
Motivation
In the Linear MCP + OpenSpec SDD Workflow article and demonstration video, I had demonstrated how integrating Linear with OpenSpec's spec-driven development workflow helps teams use their existing backlog and also have feedback loop between issue tracking and AI-assisted implementation. However, this integration required forking OpenSpec and modifying
slash-command-templates.tsdirectly.You can see the working Linear integration in PR #548, where Linear MCP instructions are hard-coded into the slash command templates. This PR generalizes that pattern into a hooks system, allowing any project to define custom integrations by simply adding markdown files to
openspec/hooks/{integration}/.How It Works
Changes
lifecycle-hooksspec defining hook discovery and injectionRelated Links
🤖 Generated with Claude Code
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.