Configure Claude Code permissions for repo plugin operations
Configures Claude Code permissions for safe repository operations without constant prompts.
/plugin marketplace add fractary/claude-plugins/plugin install fractary-repo@fractaryclaude-haiku-4-5Configure Claude Code permissions in .claude/settings.json to allow repository operations while preventing dangerous commands.
This command:
Philosophy: This configuration carefully balances agent autonomy with safety - maximizing productivity while protecting against catastrophic mistakes.
# Initial setup (creates or updates .claude/settings.json)
/repo:init-permissions
# Setup with explicit mode
/repo:init-permissions --mode setup
# Validate existing permissions
/repo:init-permissions --mode validate
# Reset to defaults (remove repo permissions)
/repo:init-permissions --mode reset
--mode <setup|validate|reset> (optional, default: setup)
setup - Configure permissions (first time or update)validate - Check if permissions are correctly configuredreset - Remove repo-specific permissionsThe following commands are explicitly allowed (no prompts):
git status, branch, checkout, switchgit commit, push, pull, fetchgit tag, log, diff, stashgit merge, rebase, rev-parsegit for-each-ref, ls-remote, show-refgit add, reset, show, configgh pr create, view, list, comment, review, merge, close, statusgh issue create, view, list, comment, closegh repo view, clonegh auth status, login, refreshgh workflow list, viewgh secret listgh app list, viewgh api (safe API calls)gh workflow run, enable, disable (could trigger CI/CD or disable critical workflows)gh secret set (could overwrite important secrets)git push origin main/master/productioncat, head, tail, grep, find, ls, pwdjq, sed, awk, sort, uniq, wcThe following dangerous commands are explicitly blocked:
rm -rf /, rm -rf *, rm -rf ., rm -rf ~dd if=, mkfs, format> /dev/sd)git push --force origin main (or master, production)git reset --hard origin/git clean -fdxgit filter-branch, git rebase --ontogh repo delete, gh repo archivegh secret delete, gh secret removesudo, su, chmod 777, chownkill -9, pkillshutdown, reboot, init, systemctlcurl | sh, wget | sh (pipe to shell)/repo:init-permissions
Output:
╔════════════════════════════════════════════════════════════════════╗
║ Permission Configuration Philosophy ║
╚════════════════════════════════════════════════════════════════════╝
We carefully balance agent autonomy with safety:
✓ MAXIMIZE AUTONOMY: Auto-approve safe operations so you're not
constantly clicking 'yes' for routine git/GitHub commands.
⚠️ PROTECT CRITICAL PATHS: Require explicit approval for operations
on protected branches (main/master/production) to prevent accidents.
✗ BLOCK CATASTROPHIC MISTAKES: Deny destructive operations that could
destroy your repo, system, or execute remote code.
This configuration lets the agent work efficiently while keeping you safe.
───────────────────────────────────────────────────────────────────
📊 Permission Changes Summary
───────────────────────────────────────────────────────────────────
New Permissions to Add:
✅ 10 safe git read operations
(git status, git branch, log, diff, git show, ...)
✅ 13 git write operations
(git add, git checkout, git switch, git fetch, git pull, ...)
✅ 7 GitHub read operations
(gh pr view, gh pr list, gh pr status, gh issue view, gh issue list, ...)
✅ 16 GitHub write operations
(gh pr create, gh pr comment, gh pr review, gh workflow list/view, gh secret list, ...)
✅ 15 safe utility commands
(cat, head, tail, grep, find, ...)
⚠️ 13 operations requiring approval
(git push origin main/master/production, gh workflow run/enable/disable, gh secret set, ...)
❌ 8 destructive file operations
(rm -rf /, rm -rf *, rm -rf ., rm -rf ~, ...)
❌ 15 dangerous git operations
(git push --force origin main, git push --force origin master, git push --force origin production, ...)
❌ 4 dangerous GitHub operations
(gh repo delete, gh repo archive, gh secret delete, gh secret remove)
❌ 9 system operations
(sudo, su, chmod 777, chown, kill -9, ...)
❌ 4 remote code execution patterns
(curl | sh, wget | sh, curl | bash, wget | bash)
───────────────────────────────────────────────────────────────────
📋 Detailed Permission Breakdown
───────────────────────────────────────────────────────────────────
══════ NEW AUTO-ALLOWED COMMANDS (No prompts) ══════
Git Read Operations (10 commands)
Check repository state without modifying anything
Why: These are 100% safe - they only read info, never modify your repo
• git status
• git branch
• git log
... and 7 more
[... additional detailed categories ...]
───────────────────────────────────────────────────────────────────
Benefits of This Configuration:
✓ Smooth workflow - No interruptions for routine operations
✓ Smart protection - Approval required only for risky operations
✓ Safety net - Catastrophic mistakes blocked automatically
✓ Team friendly - Prevents accidentally breaking shared branches
✓ Security first - Blocks common attack patterns and dangerous commands
───────────────────────────────────────────────────────────────────
Do you want to apply these permission changes?
Type yes to apply, or no to cancel: yes
Applying changes...
✅ Updated settings
Settings file: .claude/settings.json
Backup: .claude/settings.json.backup
Commands auto-allowed: 61
Operations requiring approval: 13
Dangerous operations (denied): 40
Fast workflow enabled! Most operations won't prompt.
Protected: Operations on main/master/production require approval.
/repo:init-permissions --mode validate
Output:
🔐 Validating Permissions
✓ Git commands: allowed
✓ GitHub CLI commands: allowed
✓ Dangerous commands: denied
✓ Settings file: valid JSON
All permissions correctly configured
/repo:init-permissions --mode reset
Output:
⚠ Resetting Permissions
This will remove all repo-specific permissions
✅ Reset complete
Removed repo-specific permissions
Backup: .claude/settings.json.backup
Every change creates a backup:
.claude/settings.json.backup - Before any modificationsIf something goes wrong:
# Restore from backup
mv .claude/settings.json.backup .claude/settings.json
# Or reset and start over
/repo:init-permissions --mode reset
All changes are validated:
Run this before using repo plugin commands:
/repo:init-permissions
/repo:branch create 123 "my feature" # Now works without prompts
If new commands are added to the plugin:
/repo:init-permissions --mode setup # Updates to latest permissions
If you start seeing permission prompts again:
/repo:init-permissions --mode validate # Check what's wrong
/repo:init-permissions --mode setup # Fix it
Periodically validate permissions:
/repo:init-permissions --mode validate
cat .claude/settings.json # Review manually
rm -rf / commandsgh repo deletesudocurl | shFollowing security best practices:
.claude/settings.json - Main settings file.claude/settings.json.backup - Backup before changesThis command works seamlessly with other repo commands:
# Setup permissions first
/repo:init-permissions
# Then use repo commands without prompts
/repo:branch create 123 "add export"
/repo:commit "Add CSV export" --type feat --work-id 123
/repo:push --set-upstream
/repo:pr create "feat: Add CSV export" --work-id 123
ERROR: Cannot write to .claude/settings.json
Solution:
# Check directory permissions
ls -la .claude/
# Create directory with proper permissions
mkdir -p .claude && chmod 755 .claude
ERROR: Existing settings.json contains invalid JSON
Solution:
# Restore backup
mv .claude/settings.json.backup .claude/settings.json
# Or reset to defaults
/repo:init-permissions --mode reset
# Or fix manually
vim .claude/settings.json
# Validate configuration
/repo:init-permissions --mode validate
# Re-run setup
/repo:init-permissions --mode setup
# Check if command matches allow list
cat .claude/settings.json | jq '.permissions.bash.allow'
The command invokes the repo-manager agent with a configure-permissions operation, which routes to the permission-manager skill. The skill then:
.claude/settings.json (if any){
"permissions": {
"bash": {
"allow": [
"git status",
"git commit",
"gh pr create",
"..."
],
"deny": [
"rm -rf /",
"git push --force origin main",
"..."
]
}
}
}
plugins/repo/skills/permission-manager/scripts/update-settings.sh
/repo:init - Initial repo plugin setup (creates config.json only, prompts to run this command afterward)/repo:branch - Create and manage branches (benefits from permissions)/repo:commit - Create commits (benefits from permissions)/repo:pr - Manage pull requests (benefits from permissions)Pro Tip: Run /repo:init-permissions immediately after installing the repo plugin to have a smooth, prompt-free experience with repository operations.
<CRITICAL_RULES> YOU MUST:
YOU MUST NOT:
THIS COMMAND IS ONLY A ROUTER. </CRITICAL_RULES>
<WORKFLOW> 1. **Parse user input** - Extract `--mode` argument (default: "setup") - Validate mode is one of: setup, validate, resetBuild structured request
Invoke agent
Return response
<ARGUMENT_PARSING>
--mode <setup|validate|reset> (optional, default: "setup")
setup - Configure permissions for first time or updatevalidate - Check current permissions are sufficientreset - Remove repo-specific permissionsAll modes map to: configure-permissions operation in permission-manager skill
</ARGUMENT_PARSING>
<AGENT_INVOCATION>
CRITICAL: After parsing arguments, you MUST actually invoke the Task tool. Do NOT just describe what should be done.
How to invoke: Use the Task tool with these parameters:
Example Task tool invocation (customize based on the specific operation):
Request structure:
{
"operation": "configure-permissions",
"parameters": {
"mode": "setup|validate|reset",
"project_path": "/path/to/current/directory"
}
}
The repo-manager agent will:
configure-permissions - Configure Claude Code permissions for repo operationsDO NOT:
<ERROR_HANDLING> Common errors to handle:
Invalid mode:
Error: Invalid mode '{mode}'
Valid modes: setup, validate, reset
Usage: /repo:init-permissions [--mode <setup|validate|reset>]
Permission denied:
Error: Cannot write to .claude/settings.json
Run: mkdir -p .claude && chmod 755 .claude
Invalid JSON in existing settings:
Error: Existing settings.json contains invalid JSON
Solutions:
1. Restore backup: mv .claude/settings.json.backup .claude/settings.json
2. Reset: /repo:init-permissions --mode reset
</ERROR_HANDLING>