Skip to content

fix: quote CLAUDE_PLUGIN_ROOT in hook commands to support paths with spaces#212

Merged
scottschreckengaust merged 2 commits into
awslabs:mainfrom
Sagargupta16:fix/quote-claude-plugin-root
Jul 8, 2026
Merged

fix: quote CLAUDE_PLUGIN_ROOT in hook commands to support paths with spaces#212
scottschreckengaust merged 2 commits into
awslabs:mainfrom
Sagargupta16:fix/quote-claude-plugin-root

Conversation

@Sagargupta16

@Sagargupta16 Sagargupta16 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Problem

The `aws-serverless` and `deploy-on-aws` PostToolUse hooks pass `${CLAUDE_PLUGIN_ROOT}` directly to `/bin/sh -c` with no quoting and no explicit interpreter. When `CLAUDE_CONFIG_DIR` (and therefore `CLAUDE_PLUGIN_ROOT`) contains a space -- e.g. `/Users/me/Work/Company Name/.claude` or `C:\Users\First Last.claude\plugins...` -- the shell word-splits the expanded path and the hook fails on every `Edit`/`Write`:

```
PostToolUse:Edit hook error
Failed with non-blocking status code: /bin/sh: /Users/me/Work/Company: is a directory
```

Fix

Wrap the interpolated path in escaped double quotes and prefix with `bash`, matching the pattern used by `superpowers` in `anthropics/claude-plugins-official`:

```diff

  • "command": "${CLAUDE_PLUGIN_ROOT}/scripts/validate-template.sh",
  • "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/validate-template.sh\"",
    ```

Files touched

  • `plugins/aws-serverless/hooks/hooks.json` -- primary bug from the issue
  • `plugins/deploy-on-aws/hooks/hooks.json` -- same pattern, same failure mode; fixed for parity
  • `plugins/databases-on-aws/scripts/README.md` -- doc example that would have taught the broken form; updated so copy-pasters don't hit the same bug

Space-free paths are unaffected (double quotes and `bash` are no-ops on well-formed paths).

Testing

  • Verified all three JSON files parse (`python -c 'import json; json.load(...)'`).
  • Manually confirmed the fixed hook works on a fake plugin under a path with a literal space (`/tmp/dir with space/scripts/x.sh` -- resolves without shell error).

Closes #146


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.

…spaces

The aws-serverless and deploy-on-aws hooks passed ${CLAUDE_PLUGIN_ROOT}
directly to /bin/sh -c without quoting or a bash prefix. When
CLAUDE_CONFIG_DIR contains a space (e.g. /Users/me/Work/Company Name/),
the shell word-splits the path and the hook fails on every Edit/Write
with:

    /bin/sh: /Users/me/Work/Company: is a directory

Wrap the interpolated path in escaped double quotes and prefix with
bash, matching the pattern used by superpowers in
anthropics/claude-plugins-official. Applied the same pattern to the
databases-on-aws scripts README example so users don't copy the
broken form.

Closes #146

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes PostToolUse hook command strings to work when CLAUDE_PLUGIN_ROOT contains spaces (e.g., paths under .../Company Name/...) by invoking scripts via bash and quoting the interpolated script path (and, in docs, quoting example arguments too). This aligns hook behavior across aws-serverless and deploy-on-aws and prevents shell word-splitting failures.

Changes:

  • Quote ${CLAUDE_PLUGIN_ROOT} in hook command strings and prefix with bash for reliable execution.
  • Apply the same fix to both aws-serverless and deploy-on-aws hook configs for parity.
  • Update the databases-on-aws scripts README hook example to use the safe quoted form (including quoting $CLUSTER and $REGION).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
plugins/aws-serverless/hooks/hooks.json Quotes ${CLAUDE_PLUGIN_ROOT} and runs validation script via bash to prevent failures on space-containing paths.
plugins/deploy-on-aws/hooks/hooks.json Applies the same bash + quoted ${CLAUDE_PLUGIN_ROOT} pattern to the drawio validation hook.
plugins/databases-on-aws/scripts/README.md Updates the documented hook example to use quoted script path and arguments, avoiding copy/paste breakage.

@scottschreckengaust scottschreckengaust left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@scottschreckengaust
scottschreckengaust added this pull request to the merge queue Jul 8, 2026
Merged via the queue into awslabs:main with commit efe040a Jul 8, 2026
22 of 24 checks passed
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.

Bug: Unquoted $CLAUDE_PLUGIN_ROOT in aws-serverless hook breaks on paths with spaces

5 participants