Skip to content

Add PreToolUse:Bash hook for OPC script directory guard#1

Merged
Lisztos merged 1 commit intomainfrom
fix/opc-directory-guard
Mar 25, 2026
Merged

Add PreToolUse:Bash hook for OPC script directory guard#1
Lisztos merged 1 commit intomainfrom
fix/opc-directory-guard

Conversation

@Lisztos
Copy link
Copy Markdown
Owner

@Lisztos Lisztos commented Mar 24, 2026

Ported from parcadei/Continuous-Claude-v3#160 by @yurukusa


Summary

Adds a PreToolUse:Bash hook that prevents scripts/(mcp|core)/ from running outside the OPC directory. Without this guard, uv run misses opc/pyproject.toml and its dependencies, causing ModuleNotFoundError.

  • Detects Bash commands referencing scripts/(mcp|core)/ paths
  • Blocks execution unless prefixed with cd $CLAUDE_OPC_DIR && (or the resolved path)
  • Returns a deny message with the corrected command so Claude can retry immediately

Test plan

  • Run a Bash command with scripts/mcp/ path without cd prefix — should be denied
  • Run the same command with cd $CLAUDE_OPC_DIR && prefix — should pass through
  • Verify hook exits cleanly when OPC dir is not available

Prevents running scripts/(mcp|core)/ from wrong directory by requiring
cd $CLAUDE_OPC_DIR && prefix. Without this, uv run misses pyproject.toml
and causes ModuleNotFoundError.

Fixes parcadei#148

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Lisztos Lisztos force-pushed the fix/opc-directory-guard branch from 8847924 to e7b514c Compare March 25, 2026 03:07
@Lisztos Lisztos merged commit 23451d2 into main Mar 25, 2026
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.

2 participants