Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Use when user asks to leverage claude or claude code to do something (e.g. implement a feature design or review codes, etc). Provides non-interactive automation mode for hands-off task execution without approval prompts.
.claude/skills/majiayu000-claude-skill/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 96% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 115% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 138% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 236% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 67% | 0% |
You are operating in Claude Code headless mode - a non-interactive automation mode for hands-off task execution.
Before using this skill, ensure Claude Code CLI is installed and configured:
bash claude --version
npm install -g @anthropic-ai/claude-code.references/examples.md.Claude Code uses permission modes to control what operations are permitted. Set via --permission-mode flag:
| Mode | Description | |------|-------------| | default | Standard behavior - prompts for permission on first use of each tool | | acceptEdits | Automatically accepts file edit permissions for the session (Default for this skill) | | plan | Plan Mode - Claude can analyze but not modify files or execute commands | | bypassPermissions | Skips all permission prompts (requires safe environment - see warning below) |
Accept Edits Mode (--permission-mode acceptEdits) - Default
Default Mode (--permission-mode default)
Plan Mode (--permission-mode plan)
Bypass Permissions Mode (--permission-mode bypassPermissions)
--allowedTools to restrict specific tools for safetyNote: The following commands are based on the official Claude Code headless mode documentation.
Use the --print (or -p) flag to run in non-interactive mode:
bashclaude -p "analyze the codebase structure and explain the architecture"
Control which tools Claude can use with --allowedTools and --disallowedTools:
bash# Allow specific tools claude -p "stage my changes and write commits" \ --allowedTools "Bash,Read" \ --permission-mode acceptEdits # Allow multiple tools (space-separated) claude -p "implement the feature" \ --permission-mode acceptEdits \ --allowedTools Bash Read Write Edit # Allow tools with restrictions (comma-separated string) claude -p "run tests" \ --permission-mode acceptEdits \ --allowedTools "Bash(npm test),Read" # Disallow specific tools claude -p "analyze the code" \ --disallowedTools "Bash,Write"
Control how permissions are handled:
bash# Accept file edits automatically (recommended for programming) claude -p "implement the user authentication feature" \ --permission-mode acceptEdits \ --allowedTools "Bash,Read,Write,Edit" # Combine with allowed tools for safe automation claude -p "fix the bug in login flow" \ --permission-mode acceptEdits \ --allowedTools "Read,Write,Edit,Bash(npm test)"
bashclaude -p "explain file src/components/Header.tsx" # Output: Plain text response
Returns structured data including metadata:
bashclaude -p "how does the data layer work?" --output-format json
Response format:
json{ "type": "result", "subtype": "success", "total_cost_usd": 0.003, "is_error": false, "duration_ms": 1234, "duration_api_ms": 800, "num_turns": 6, "result": "The response text here...", "session_id": "abc123" }
Streams each message as it is received:
bashclaude -p "build an application" \ --permission-mode acceptEdits \ --output-format stream-json
Each conversation begins with an initial init system message, followed by user and assistant messages, followed by a final result system message with stats.
For multi-turn conversations, you can resume or continue sessions:
bash# Continue the most recent conversation claude --continue --permission-mode acceptEdits "now refactor this for better performance" # Resume a specific conversation by session ID claude --resume 550e8400-e29b-41d4-a716-446655440000 \ --permission-mode acceptEdits "update the tests" # Resume in non-interactive mode claude --resume 550e8400-e29b-41d4-a716-446655440000 -p \ --permission-mode acceptEdits "fix all linting issues" # Short flags claude -c --permission-mode acceptEdits "continue with next step" claude -r abc123 -p --permission-mode acceptEdits "implement the next feature"
Append custom instructions to the system prompt:
bashclaude -p "review this code" \ --append-system-prompt "Focus on security vulnerabilities and performance issues"
Load MCP servers from a JSON configuration file:
bashclaude -p "analyze the metrics" \ --mcp-config monitoring-tools.json \ --allowedTools "mcp__datadog,mcp__prometheus"
Enable verbose output for debugging:
bashclaude -p "debug this issue" --verbose
Combine multiple flags for complex scenarios:
bash# Full automation with JSON output claude -p "implement authentication and output results" \ --permission-mode acceptEdits \ --allowedTools "Bash,Read,Write,Edit" \ --output-format json # Multi-turn with custom instructions session_id=$(claude -p "start code review" --output-format json | jq -r '.session_id') claude -r "$session_id" -p "now check for security issues" \ --permission-mode acceptEdits \ --append-system-prompt "Be thorough with OWASP top 10" # Streaming with MCP tools claude -p "deploy the application" \ --permission-mode acceptEdits \ --output-format stream-json \ --mcp-config deploy-tools.json \ --allowedTools "mcp__kubernetes,mcp__docker"
bash timeout 300 claude -p "$complex_prompt" --permission-mode acceptEdits || echo "Timed out after 5 minutes"
Only pause for user input when encountering:
For all other decisions, proceed autonomously using best judgment.
Always conclude with a structured summary:
text✓ Task completed successfully Changes made: - [List of files modified/created] - [Key code changes] Results: - [Metrics: lines changed, files affected, tests run] - [What now works that didn't before] Verification: - [Tests run, checks performed] Next steps (if applicable): - [Suggestions for follow-up tasks]
See references/examples.md for extended usage scenarios.
When errors occur:
If execution is interrupted:
claude --resume <session_id> -p "continue" --permission-mode acceptEditsOther measured skills in the registry, with their headline benchmark lift.