Example Usage Scenarios
Use these as patterns, not rigid templates. Keep commands aligned with the installed claude --help output on the target machine.
Use these as patterns, not rigid templates. Keep commands aligned with the installed claude --help output on the target machine.
Use these as patterns, not rigid templates. Keep commands aligned with the installed `claude --help` output on the target machine.
**User**: "Use Claude Code to explain this codebase structure without changing anything."
claude -p "explain the codebase structure, major entry points, and risks for future refactors" \
--tools "Read,Grep,Glob"Why this works:
**User**: "Use Claude Code headless mode to fix the authentication bug and run the relevant tests."
claude -p "fix the authentication bug in the login flow and run the relevant tests" \
--permission-mode acceptEdits \
--tools "Bash,Read,Edit,Write" \
--allowedTools "Read" "Edit" "Write" "Bash(npm test *)"Why this works:
**User**: "Update imports from `old-lib` to `new-lib` across the repo."
claude -p "update imports from old-lib to new-lib across the repository and report the affected files" \
--permission-mode acceptEdits \
--tools "Bash,Read,Edit,Write" \
--allowedTools "Read" "Edit" "Write" "Bash(npm run test *)"**User**: "Review the current repository for security issues and return JSON."
claude -p "review the repository for security vulnerabilities and provide a concise report" \
--output-format json \
--append-system-prompt "Focus on concrete findings, exploitability, and mitigations."Why this works:
**User**: "Continue the session and add tests for the refactor."
claude -r "$session_id" -p "continue by adding tests for the refactor and summarizing the result"**User**: "Pick up where Claude Code left off."
claude -c -p "continue with the next step"**User**: "Use Claude Code plus my monitoring MCP servers to investigate payment API latency."
claude -p "investigate the payment API latency spike and summarize likely causes" \
--permission-mode acceptEdits \
--mcp-config monitoring-tools.json \
--allowedTools "Read" "mcp__datadog__*" "mcp__prometheus__*"**User**: "Run Claude Code without permission prompts inside my CI container."
claude -p "apply the requested changes and run the validation steps" \
--permission-mode bypassPermissions \
--tools "Bash,Read,Edit,Write"Use this only when the environment is already isolated. If the environment is not isolated, prefer `dontAsk` plus preconfigured permission rules or `acceptEdits` plus targeted `--allowedTools`.
**User**: "Give me a read-only Claude Code command that counts lines of code by language."
claude -p "Count lines of code in this repository by language. Stay read-only and use only the find and wc shell families plus file reads." \
--permission-mode default \
--tools "Read,Bash" \
--allowedTools "Read" "Bash(find:*)" "Bash(wc:*)"Why this works: