Skip to content

Allow npm build/lint/format in Claude workflows#793

Merged
danbarr merged 2 commits into
mainfrom
claude-workflow-npm-tools
Apr 22, 2026
Merged

Allow npm build/lint/format in Claude workflows#793
danbarr merged 2 commits into
mainfrom
claude-workflow-npm-tools

Conversation

@danbarr
Copy link
Copy Markdown
Collaborator

@danbarr danbarr commented Apr 22, 2026

Description

Two Claude Code workflows in this repo were missing the tooling needed to run the project's npm run build, prettier, and eslint scripts:

  • upstream-release-docs.yml already tried to run them (the skill's Phase 5 validation calls out "run the project's lint/format commands"), but the sandbox allowlist only exposed Bash(gh:*). A dedicated post-step currently auto-fixes lint/format drift to cover the gap.
  • claude.yml (the @claude mention flow) had no Node/deps setup at all and no claude_args, so any mention-triggered edit to docs content would land unformatted and break PR CI.

This PR:

  1. Adds Bash(npm run build:*) Bash(npm run prettier:*) Bash(npm run eslint:*) to --allowed-tools in both workflows. Wildcarded patterns cover the :fix variants.
  2. Wires the mention workflow through the shared ./.github/actions/setup composite so Node 24 + cached deps are present before the Claude step runs.
  3. Updates AGENTS.md (the source file behind the CLAUDE.md symlink) to stop telling Claude "the pre-commit hook handles formatting, don't run formatters manually." That's true only on a dev machine that has Node, deps, and husky set up. The hook silently no-ops in CI, scheduled agents, and local envs without npm install, so the guidance now explicitly tells Claude to run prettier:fix and eslint:fix itself.

The post-step autofix in upstream-release-docs.yml is intentionally left in place until we've seen the new allowlist work on a real release.

Type of change

  • Navigation/structure change (workflow + AGENTS.md)

Related issues/PRs

None.

Submitter checklist

Content and formatting

  • I have reviewed the content for technical accuracy
  • I have reviewed the content for spelling, grammar, and style

Add npm run build, prettier, and eslint (including :fix variants) to
the --allowed-tools allowlist in both the upstream-release-docs and
@claude mention workflows, so agents can validate their own changes
without hitting sandbox denials.

The mention workflow also gains Node + deps via the shared
./.github/actions/setup composite, since it previously had no npm
tooling at all.

Clarify CLAUDE.md/AGENTS.md: the pre-commit hook silently no-ops in
CI, unattended agents, and local environments without npm install, so
agents should run prettier:fix and eslint:fix explicitly after
editing content.
Copilot AI review requested due to automatic review settings April 22, 2026 21:21
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs-website Ready Ready Preview, Comment Apr 22, 2026 9:32pm

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 updates the repo’s Claude Code GitHub Actions workflows and agent guidance so Claude can run the project’s npm build/lint/format scripts in CI contexts where pre-commit hooks aren’t available.

Changes:

  • Expand Claude’s --allowed-tools in upstream-release-docs.yml to permit npm run build/prettier/eslint (including :fix variants).
  • Update the @claude mention workflow to run the shared ./.github/actions/setup (checkout + Node 24 + cached deps) and allow npm build/lint/format commands.
  • Revise AGENTS.md guidance to explicitly instruct running npm run prettier:fix and npm run eslint:fix instead of relying on pre-commit hooks.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
AGENTS.md Updates agent guidance to manually run format/lint scripts when hooks don’t fire.
.github/workflows/upstream-release-docs.yml Allows Claude to run npm build/lint/format scripts during upstream release doc generation/review.
.github/workflows/claude.yml Adds repo+deps setup and permits npm build/lint/format execution for mention-triggered Claude runs.

Comment on lines +41 to +42
claude_args: |
--allowed-tools "Bash(npm run build:*) Bash(npm run prettier:*) Bash(npm run eslint:*)"
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@copilot this should be addressed now, re-check

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.

Re-checked: this is addressed in 663249f. The workflow now gates @claude execution to OWNER/MEMBER/COLLABORATOR author associations before any npm-capable Bash tools can run.

The initial version of this workflow referenced `./.github/actions/setup`
without a prior checkout, so GitHub couldn't resolve the local action.
Add a sparse-checkout of `.github` just for action resolution; the
composite does its own full checkout + Node + deps.

Also gate the job on `author_association` per Copilot's review. Without
this, an @claude mention on a fork PR that modified package.json
scripts would run attacker-controlled code under our secrets and write
permissions. Only OWNER/MEMBER/COLLABORATOR can trigger the workflow.
@danbarr danbarr merged commit 3b37699 into main Apr 22, 2026
6 checks passed
@danbarr danbarr deleted the claude-workflow-npm-tools branch April 22, 2026 21:34
rdimitrov added a commit that referenced this pull request Apr 23, 2026
PR #793 added `Bash(npm run prettier:*)` etc. to --allowed-tools,
intending the wildcard to cover the `:fix` variants. It doesn't:
in Claude Code's permission grammar, the `:*` suffix is aliased to
a space-separated arg wildcard (Bash(foo:*) == Bash(foo *)), which
enforces a word boundary. `npm run prettier:fix` has no space after
`prettier` -- the `:fix` is part of the script name, not an arg --
so the pattern never matches and the command keeps prompting for
approval.

Replace the wildcarded patterns with explicit script names for the
five scripts the workflows actually invoke (`build`, `prettier`,
`prettier:fix`, `eslint`, `eslint:fix`).

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.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.

4 participants