chore(claude): enforce per-package openspec, block root specs#2348
chore(claude): enforce per-package openspec, block root specs#2348iobuhov wants to merge 1 commit into
Conversation
…x docs Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
AI Code Review
What was reviewed
Skipped (out of scope): All CI checks passed ✅ Findings
|
What
Adds a guardrail so agents can no longer create OpenSpec specs/changes at the monorepo root. Specs/changes must live per-package.
Why
OpenSpec resolves its
openspec/directory relative to the current working directory and does not walk up the tree. Since agents run from the repo root, everyopenspec new changeand every/opsxartifact write landed in the rootopenspec/. In a monorepo, specs should live inside the relevant package.Changes
PreToolUsehook.claude/hooks/validate-openspec-path.sh(registered in.claude/settings.jsonforBash|Write|Edit|MultiEdit):openspec/changes/**andopenspec/specs/**(the reliable backstop).openspec new/init/archiveunless the commandcds into apackages/…dir first.openspec/…writes, read-only commands (openspec list), and rootconfig.yaml.AGENTS.md— documents the per-package rule./opsx:newand/opsx:propose— updated tocdinto the target package before running openspec.Testing
Manually exercised the hook against 18 block/allow cases (absolute + relative paths, with and without
CLAUDE_PROJECT_DIR, edge/bypass attempts) — all behave as expected. The Bash rule is a heuristic early-error; the Write/Edit backstop is the real enforcement and catches root-spec file creation regardless of how the directory was made.🤖 Generated with Claude Code