Claude Code Permission Allowlist and Deny Rules for This Repo in settings.json

Has Claude Code read your repo's scripts and CI, then propose allow, ask and deny permission rules with a reason for each, split into shared and local settings files, plus commands to test them.

You geta table of Rule, List, File, Reason; then the JSON for each file; then a test of three commands that should run without a prompt and three that should be blocked. Rule syntax…

Prompt

Prompt
You are working in this repository in Claude Code. Build a permissions block for .claude/settings.json from the commands this repo actually uses.

Steps:
1. Read package.json scripts, any Makefile, justfile or Taskfile, and the CI workflow files. List the read-only, build, lint and test commands.
2. Propose permissions.allow rules as exact patterns in Claude Code rule syntax, such as Bash(npm run test:*) or Read(./src/**). Allow only commands that cannot delete data, publish, or reach production.
3. Propose permissions.deny rules for: rm -rf, git push --force, git reset --hard, reading .env files and key or secret files, and any deploy, migrate or publish command aimed at production.
4. Propose permissions.ask rules for actions that are fine after a check: git push, installing packages, migrations on local or staging.
5. Split the rules between .claude/settings.json (shared, committed) and .claude/settings.local.json (personal, not committed).

Rules: give a one-line reason for every rule; Bash deny patterns match command prefixes and can be sidestepped (a script, an alias, another flag order), so for anything destructive also say whether sandboxing or a PreToolUse hook is the safer guard; if a command's effect is unclear, put it under ask and say why; do not write any file until I approve.

Output format: a table of Rule, List, File, Reason; then the JSON for each file; then a test of three commands that should run without a prompt and three that should be blocked. Rule syntax changes between releases, so check it against the current Claude Code permissions docs before saving.

Example output

At a glancePermission rules proposed for the ledgerline repoRules split across shared settings.json and personal settings.local.json
Allow rules
9
Lint, typecheck, tests, build, git reads, source reads
Ask rules
5
3 shared, 2 in settings.local.json
Deny rules
8
Deletion, force push, secrets, prod deploy, migrations

Example for: a TypeScript monorepo ("ledgerline") using pnpm, a Makefile, and GitHub Actions CI with Prisma migrations.

Commands found: pnpm run lint, pnpm run typecheck, pnpm run test, pnpm run test:e2e, pnpm run build, make db-migrate-local, make deploy-prod (CI only), pnpm prisma migrate deploy (CI, production), git status/diff/log.

RuleListFileReason
Bash(pnpm run lint:*)allowsettings.jsonRead-only static analysis
Bash(pnpm run typecheck)allowsettings.jsonCompiler check, no writes outside cache
Bash(pnpm run test:*)allowsettings.jsonUnit tests use in-memory DB
Bash(pnpm run build)allowsettings.jsonWrites only to dist/
Bash(git status), Bash(git diff:*), Bash(git log:*)allowsettings.jsonRead-only git inspection
Read(./src/**), Read(./packages/**)allowsettings.jsonSource reading
Bash(rm -rf:*)denysettings.jsonIrreversible deletion; also use sandbox, since a prefix rule misses rm -r -f
Bash(git push --force:*)denysettings.jsonRewrites shared history; add a PreToolUse hook to catch -f and --force-with-lease
Bash(git reset --hard:*)denysettings.jsonDiscards uncommitted work; a hook is the safer guard
Read(./.env*), Read(./**/*.pem), Read(./secrets/**)denysettings.jsonCredential exposure
Bash(make deploy-prod:*)denysettings.jsonProduction deploy; a hook should also block scripts/deploy.sh
Bash(pnpm prisma migrate deploy:*)denysettings.jsonApplies migrations to the target DB; a hook should check DATABASE_URL
Bash(git push:*)asksettings.jsonFine after reviewing the branch
Bash(pnpm add:*), Bash(pnpm install:*)asksettings.jsonSupply-chain risk; check the package
Bash(make db-migrate-local)asksettings.local.jsonLocal DB only, but the target depends on a personal .env.local
Bash(pnpm run test:e2e)asksettings.local.jsonUnclear effect: it hits the staging API if E2E_TARGET is set

.claude/settings.json

{
  "permissions": {
    "allow": [
      "Bash(pnpm run lint:*)",
      "Bash(pnpm run typecheck)",
      "Bash(pnpm run test:*)",
      "Bash(pnpm run build)",
      "Bash(git status)",
      "Bash(git diff:*)",
      "Bash(git log:*)",
      "Read(./src/**)",
      "Read(./packages/**)"
    ],
    "ask": [
      "Bash(git push:*)",
      "Bash(pnpm add:*)",
      "Bash(pnpm install:*)"
    ],
    "deny": [
      "Bash(rm -rf:*)",
      "Bash(git push --force:*)",
      "Bash(git reset --hard:*)",
      "Read(./.env*)",
      "Read(./**/*.pem)",
      "Read(./secrets/**)",
      "Bash(make deploy-prod:*)",
      "Bash(pnpm prisma migrate deploy:*)"
    ]
  }
}

.claude/settings.local.json (add to .gitignore)

{
  "permissions": {
    "ask": [
      "Bash(make db-migrate-local)",
      "Bash(pnpm run test:e2e)"
    ]
  }
}

Note: test:e2e matches the shared allow rule pnpm run test:*. Ask takes precedence over allow, so the local ask rule should still prompt. Confirm this precedence in the docs.

Test

These should run without a prompt:

pnpm run lint
pnpm run test:unit
git diff HEAD~1

These should be blocked:

rm -rf dist
git push --force origin main
cat .env.production   # Read deny covers the Read tool only; Bash cat needs a hook or sandbox

Rule syntax and precedence may differ between releases. Check this against the current Claude Code permissions docs before saving. No files have been written. Reply "approve" to create them.

Written by AI from this prompt. Your results will vary.

Run in Claude Code at the root of a repo. Review the table, approve, then try the six test commands and run /permissions to confirm the rules loaded.

Make it repeatable

Keep using this prompt without pasting it in every time.

Prompt details

By
Prompts-GPT editors
Published
How prompts are written and checked

Did this prompt work?

Keep exploring

More in Claude Code