Skip to content

Feature/compound command validation#27928

Open
Agentscreator wants to merge 2 commits intoanthropics:mainfrom
Agentscreator:feature/compound-command-validation
Open

Feature/compound command validation#27928
Agentscreator wants to merge 2 commits intoanthropics:mainfrom
Agentscreator:feature/compound-command-validation

Conversation

@Agentscreator
Copy link
Copy Markdown

When Claude Code asks for permission to run compound shell commands (for example, sleep 10 && do-something-else), it often shows a vague prompt like “sleep *” or treats the whole chain as one command. This hides what will actually run and undermines security and user trust.

Users have reported low confidence in approving commands when they can’t clearly see what operations are included.

Solution
This PR adds compound command parsing to the hookify plugin. Commands using &&, ||, ;, or | are automatically detected and broken into clear, readable steps before permission is requested.

Instead of a vague prompt, users see a warning that a compound command was detected along with a breakdown of each operation and how it will execute. This makes it obvious what’s being approved.

What’s included
The change introduces a compound command parser, a new is_compound rule operator, and new template variables for rendering command breakdowns. It also includes example rules for warning or blocking compound commands, plus documentation and a quick start guide.

New files cover parsing logic, tests, examples, and documentation. Existing rule engine logic and the README were updated to support the feature.

Key features

Detects &&, ||, ;, and | operators

Shows a clear, ordered breakdown of commands

Correctly handles quoted strings

Supports warn or block policies

Activates immediately with no restart

Fully tested

Usage
Copy the example compound command validator rule into your local hookify config. The rule takes effect immediately.

Testing
All unit and integration tests pass.

Benefits
This improves transparency, reduces the risk of approving dangerous commands, and increases trust by clearly showing what will execute. Users gain more control and better visibility into shell behavior.

Backward compatibility
No breaking changes. Existing rules continue to work, the feature is opt-in, and no new dependencies were added.

Related feedback
ID: c85e77e9-9801-4315-84ef-64466ddb9a12

Addresses issue where compound shell commands (using &&, ||, ;, |) are not
clearly displayed in permission prompts, making it difficult to understand
what operations are being approved.

Changes:
- Add command_parser.py utility to parse and split compound commands
- Enhance rule_engine.py with 'is_compound' operator and template variables
- Add {{COMMAND_BREAKDOWN}} and {{BASE_COMMANDS}} template support
- Create example rules for warning and blocking compound commands
- Add comprehensive documentation and quick start guides
- Include integration tests validating all functionality

Features:
- Automatically detects compound commands with &&, ||, ;, | operators
- Breaks down commands into individual components with clear explanations
- Handles quoted strings correctly (e.g., echo "hello && world")
- Supports flexible policies: warn, block, or customize
- No restart required - rules activate immediately

Example output:
  1. First: `sleep 10`
  2. THEN (if successful): `echo done`
  3. OR (if failed): `echo failed`

This improves transparency and security by showing exactly what will execute
and in what order, addressing user concerns about permission system clarity.

Fixes: Compound command permission visibility issue
Feedback ID: c85e77e9-9801-4315-84ef-64466ddb9a12
Update all documentation files to use the correct product name 'Claude Code'
instead of 'Kiro' for consistency and clarity.
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