diff --git a/hooks/context.md b/hooks/context.md new file mode 100644 index 0000000..fa77b8c --- /dev/null +++ b/hooks/context.md @@ -0,0 +1,41 @@ +You have the SpecForge plugin loaded. SpecForge is a spec-driven development toolkit that turns requirements into sprint-ready work following IEEE 830 / ISO 29148 standards. + +## Available Slash Commands + +| Command | Usage | Purpose | +|---|---|---| +| `/new-spec` | `/new-spec ` | Create a spec from template (object, usecase, screen, businessrule, actor, workflow, nfr, etc.) | +| `/new-epic` | `/new-epic ` | Generate an epic from a use case | +| `/new-story` | `/new-story ` | Create a user story with spec traceability | +| `/new-sprint` | `/new-sprint ` | Create a sprint plan from ready stories | +| `/meeting-note` | `/meeting-note ` | Capture meeting notes with UR extraction | +| `/check-traceability` | `/check-traceability [scope]` | Scan for orphans and coverage gaps | +| `/phase-delta` | `/phase-delta ` | Create a Phase 2+ delta for an approved spec | +| `/change-request` | `/change-request ` | Log a formal change request | +| `/impact-analysis` | `/impact-analysis <CR code>` | Run blast-radius analysis on a CR | +| `/apply-change` | `/apply-change <CR code>` | Execute an approved change request | + +## Auto-Triggering Skills + +These activate automatically based on what you are doing — you do not need to invoke them manually: + +- **spec-writer** — activates when writing or editing any specification document +- **requirement-decomposer** — activates when decomposing specs into epics, stories, or sprints +- **traceability-checker** — activates when verifying cross-references or coverage + +## Available Agents + +Invoke these for complex multi-step tasks: + +- **spec-reviewer** — IEEE 830 / ISO 29148 quality review with scored report +- **decomposition-agent** — auto-decompose a use case into an epic + user stories +- **traceability-agent** — build or validate the full Requirements Traceability Matrix +- **change-impact-agent** — autonomous blast-radius analysis for a change request + +## Key Rules (Always Follow) + +1. **Never edit Approved specs directly** — always use `/phase-delta <spec code>` to create a Phase 2 delta. Every change must trace to a CR code. +2. **Naming conventions** — O<NN>_, UC<NNNN>_, S<NNNN>_, BR<NNNN>_, ACT<NNNN>_, WF<NNNN>_, ST<NNNN>_, PM<NNNN>_, NFR<NNNN>_, EPIC-NNNN_, US-NNNN_, SPR-NNNN_ +3. **Spec output directory** — write all generated spec artifacts to `docs/` +4. **Templates** — always copy from `templates/` when creating new specs; never create from scratch +5. **Traceability** — every user story must trace back to at least one SRS artifact (UC, Object, Screen, BR, etc.) diff --git a/hooks/hooks.json b/hooks/hooks.json index 0967ef4..6c63155 100644 --- a/hooks/hooks.json +++ b/hooks/hooks.json @@ -1 +1,18 @@ -{} +{ + "description": "SpecForge BA workflow hooks: injects plugin context at session start.", + "hooks": { + "SessionStart": [ + { + "matcher": "startup|clear|compact", + "hooks": [ + { + "type": "command", + "command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/scripts/session-start.sh\"", + "async": false, + "timeout": 10 + } + ] + } + ] + } +} diff --git a/hooks/scripts/session-start.sh b/hooks/scripts/session-start.sh new file mode 100755 index 0000000..a6de8c5 --- /dev/null +++ b/hooks/scripts/session-start.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# SpecForge SessionStart hook +# Injects SpecForge plugin context into every new Claude Code session so that +# Claude is always aware of available commands, agents, skills, and key rules. +# Pattern adapted from obra/superpowers session-start hook. + +set -euo pipefail + +PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-$(cd "$(dirname "$0")/../.." && pwd)}" +CONTEXT_FILE="${PLUGIN_ROOT}/hooks/context.md" + +if [ ! -f "$CONTEXT_FILE" ]; then + exit 0 +fi + +# Read and JSON-escape the context content (no subshells, pure bash) +content=$(<"$CONTEXT_FILE") +content="${content//\\/\\\\}" +content="${content//\"/\\\"}" +content="${content//$'\n'/\\n}" +content="${content//$'\r'/}" +content="${content//$'\t'/\\t}" + +payload="{\"hookSpecificOutput\":{\"hookEventName\":\"SessionStart\",\"additionalContext\":\"${content}\"}}" + +printf '%s' "$payload"