Skip to content

Conversation

@harikrishnan83
Copy link
Contributor

@harikrishnan83 harikrishnan83 commented Jan 21, 2026

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.ts directly.

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

openspec/hooks/
├── linear/                    # Integration namespace
│   ├── before-proposal.md     # Select Linear story
│   ├── after-proposal.md      # Move to Todo
│   ├── before-apply.md        # Update description
│   ├── after-apply.md         # Move to In Progress
│   └── after-archive.md       # Move to Done
├── slack/                     # Another integration
│   └── after-archive.md       # Notify channel
  • Convention over configuration: Drop files in folders, no config needed
  • Composable: Multiple integrations work together automatically
  • Future-proof: Works with any phase name, including custom schema phases

Changes

  • New capability: lifecycle-hooks spec defining hook discovery and injection
  • Design document detailing the convention-based approach
  • Task breakdown for implementation

Related Links


🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added lifecycle hooks system allowing custom Markdown instructions at workflow phase boundaries
    • Supports before/after hook injection points for proposal, apply, and archive phases
    • Integrations can be distributed as standalone packages with hook files
    • Multiple integrations automatically compose by concatenating hooks per phase

✏️ Tip: You can customize this high-level summary in your review settings.

harikrishnan83 and others added 2 commits January 21, 2026 09:52
- 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>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 21, 2026

📝 Walkthrough

Walkthrough

Introduces 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

Cohort / File(s) Summary
Lifecycle Hooks Design & Documentation
openspec/changes/add-lifecycle-hooks/design.md, openspec/changes/add-lifecycle-hooks/proposal.md, openspec/changes/add-lifecycle-hooks/specs/lifecycle-hooks/spec.md, openspec/changes/add-lifecycle-hooks/tasks.md
Comprehensive design documentation for injectable lifecycle hooks system including technical architecture, hook discovery mechanism from openspec/hooks/{integration}/{before|after}-{phase}.md, composition rules for concatenating hooks across integrations, injection points into phase instructions, size limits (50KB per hook), and implementation task checklist with hook discovery, template integration, testing, and documentation components.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • TabishB

Poem

🐰✨ A rabbit hops through phases new,
Hooks discovered, fresh and true,
Lifecycle whispers, integration cheer,
Custom markdowns, ever near! 🎯📝

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Lifecycle hooks' directly corresponds to the main feature introduced in this PR—a lifecycle hooks system for extensible integrations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vibe-kanban-cloud
Copy link

Review Complete

Your review story is ready!

View Story

Comment !reviewfast on this PR to re-generate the story.

@greptile-apps
Copy link

greptile-apps bot commented Jan 21, 2026

Greptile Summary

This 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:

  • Adds new lifecycle-hooks capability with complete spec defining hook discovery, composition, and injection
  • Convention-based approach: hooks discovered from openspec/hooks/{integration}/{before|after}-{phase}.md
  • Supports all lifecycle phases (proposal, apply, archive) plus custom phases from schemas
  • Multiple integrations compose automatically through alphabetical concatenation
  • Clear implementation plan with hook discovery (src/core/hooks.ts) and template integration (slash-command-templates.ts)

Strengths:

  • Excellent design documentation covering decisions, alternatives, and trade-offs
  • Comprehensive spec with proper scenario formatting following AGENTS.md guidelines
  • Future-proof: works with any phase name without code changes
  • Well-scoped tasks with clear testing and documentation requirements

Issue Found:

  • Proposal claims to modify slash-commands capability but no corresponding delta spec exists at specs/slash-commands/spec.md - needs clarification whether this is an existing capability or if template changes don't require a separate capability spec

Confidence Score: 4/5

  • This proposal is safe to merge with one minor clarification needed about capability modifications
  • Well-structured proposal following OpenSpec conventions with comprehensive specs and design documentation. The only issue is a missing delta spec for the claimed slash-commands capability modification, which needs clarification or addition.
  • Pay attention to proposal.md line 22-23 regarding the slash-commands capability modification claim

Important Files Changed

Filename Overview
openspec/changes/add-lifecycle-hooks/proposal.md Well-structured proposal defining lifecycle hooks system; missing delta spec for modified slash-commands capability
openspec/changes/add-lifecycle-hooks/design.md Comprehensive design with clear decisions, rationale, and trade-offs; excellent documentation
openspec/changes/add-lifecycle-hooks/specs/lifecycle-hooks/spec.md Complete spec with proper scenario formatting and comprehensive coverage of all requirements
openspec/changes/add-lifecycle-hooks/tasks.md Clear implementation checklist with logical breakdown and appropriate level of detail

Sequence Diagram

sequenceDiagram
    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
Loading

Copy link

@greptile-apps greptile-apps bot left a 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

Edit Code Review Agent Settings | Greptile

Comment on lines +22 to +23
### Modified Capabilities
- `slash-commands` - Extend template generation to discover and inject hooks
Copy link

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:

  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
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant