Skip to content

chore: add spec-drift detection commands and pre-commit hook#649

Open
ciscoRankush wants to merge 1 commit intonextfrom
spec-drift-tooling
Open

chore: add spec-drift detection commands and pre-commit hook#649
ciscoRankush wants to merge 1 commit intonextfrom
spec-drift-tooling

Conversation

@ciscoRankush
Copy link
Contributor

This pull request addresses

Adding automated SDD (Spec-Driven Development) documentation drift detection tooling to ensure ai-docs stay in sync with source code.

by making the following changes

  • .claude/commands/spec-drift.md — Full scan command that auto-discovers all ai-docs folders, spawns parallel checker agents, and validates 7 drift categories (file tree, method/API, types, events, architecture, links, code examples)
  • .claude/commands/spec-drift-changed.md — Incremental scan that only validates ai-docs affected by staged/unstaged file changes, with verification marker creation
  • .claude/hooks/check-ai-docs-drift.sh — Pre-commit blocking hook that prevents committing when ai-docs drift is unverified

Change Type

  • Tooling change

The following scenarios were tested

  • Verified spec-drift command discovers all ai-docs folders and produces a categorized report
  • Verified spec-drift-changed detects changed files and maps them to their ai-docs
  • Verified pre-commit hook blocks commits with unverified ai-docs changes (exit code 2)
  • Verified hook passes after spec-drift-changed creates verification marker
  • Verified hook is transparent for commits without ai-docs-related changes

The GAI Coding Policy And Copyright Annotation Best Practices

  • GAI was used to create a draft that was subsequently customized or modified
  • Tool used for AI assistance (GitHub Copilot / Other - specify)
    • Other - Claude Code (Anthropic)
  • This PR is related to
    • Automation

I certified that

  • I have read and followed contributing guidelines
  • I discussed changes with code owners prior to submitting this pull request
  • I have not skipped any automated checks
  • All existing and new tests passed
  • I have updated the documentation accordingly

Add automated SDD documentation drift detection tooling:
- /spec-drift: full scan command for validating all ai-docs against source code
- /spec-drift-changed: incremental scan for changed files only
- Pre-commit hook to block commits when ai-docs drift is unverified

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ciscoRankush ciscoRankush requested a review from a team as a code owner March 11, 2026 08:42
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 17636199d6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +20 to +22
case "$COMMAND" in
git\ commit*) ;; # Continue to check
*) exit 0 ;; # Not a commit, allow immediately

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Detect commit invocations beyond literal git commit

The hook only enforces validation when the command string starts with git commit, so commit flows like git -c user.name=... commit ..., HUSKY=0 git commit ..., or chained commands such as git add . && git commit ... will bypass this guard and allow unverified contact-center changes to be committed. Since this script is meant to be the blocking gate, matching only one command shape leaves a real enforcement hole.

Useful? React with 👍 / 👎.

esac

# Get staged files under the contact-center package
STAGED_CC=$(git diff --cached --name-only 2>/dev/null | grep "^${CC_PKG}/")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Bind verification marker to staged content, not paths

The marker hash is derived from git diff --cached --name-only output, which means it changes only when the set of staged file paths changes; if a developer runs /spec-drift-changed, then edits and restages the same files, the existing marker still matches and the commit is allowed without re-validating docs against the new content. This weakens the drift check and can let stale verification pass.

Useful? React with 👍 / 👎.

@aws-amplify-us-east-2
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-649.d1b38q61t1z947.amplifyapp.com

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