Install
$ agentstack add skill-jeffpignataro-claude-oauth-skill-claude-oauth-skill ✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
About
Claude CLI Skill
This skill enables you to invoke the Claude Code CLI directly with prompts in non-interactive mode, bypassing the workspace trust dialog.
Overview
The Claude Code CLI can be invoked in non-interactive mode using the -p or --print flag, which prints the response and exits. This is particularly useful for:
- Scripting and automation
- Piping output to other commands
- Quick one-off queries
- Integration with other tools
Important Security Note: The -p flag automatically bypasses the workspace trust dialog. Only use this in directories you trust.
OpenClaw Execution
When calling this skill from an OpenClaw agent, ALWAYS use pty:true to ensure the terminal output is handled correctly.
# Example OpenClaw tool call
bash pty:true command:"claude -p 'Your prompt'"
Automated Permission Approval
When using this skill for complex automation (e.g., orchestrating other Claude agents), you may encounter permission prompts that block the non-interactive flow. To pre-approve specific tools and commands in a project directory, create a .claude/settings.json file.
Common Language Permissions
Add these to the allow array based on the project's tech stack:
- General:
Read,Write,Edit,Bash(*) - Rust:
Bash(cargo*),Bash(rustc*) - Node/JS:
Bash(npm*),Bash(pnpm*),Bash(bun*),Bash(node*) - Python:
Bash(python*),Bash(pip*),Bash(pytest*),Bash(poetry*) - Go:
Bash(go*)
Example for a multi-stack project:
mkdir -p .claude
cat > .claude/settings.json "
Key Flags
-p, --print: Print response and exit (non-interactive mode). This automatically skips the workspace trust dialog.--model: Specify a model (e.g., 'sonnet', 'opus', or full model name)--output-format: Output format - "text" (default), "json", or "stream-json"--max-budget-usd: Set maximum spending limit for API calls--session-id: Use a specific session ID--system-prompt: Override the system prompt--tools: Specify available tools (e.g., "Bash,Edit,Read" or "" to disable all)
Examples
Simple Query
claude -p "What is the capital of France?"
Code Analysis
claude -p "Analyze the code in main.py and suggest improvements"
With Model Selection
claude -p --model opus "Explain quantum computing in simple terms"
JSON Output
claude -p --output-format json "List the top 3 programming languages"
With Budget Limit
claude -p --max-budget-usd 0.50 "Generate a Python script to parse CSV files"
Disable All Tools (API-only mode)
claude -p --tools "" "Explain the concept of recursion"
With Custom System Prompt
claude -p --system-prompt "You are a code reviewer" "Review this function for security issues"
Integration Patterns
Piping Output
claude -p "Generate a bash script to backup files" > backup.sh
chmod +x backup.sh
Chaining Commands
result=$(claude -p "What is 2+2?")
echo "Claude says: $result"
Processing Files
for file in *.py; do
claude -p "Summarize this Python file: $file"
done
When to Use This Skill
Use this skill when you need to:
- Automate Claude interactions - Scripts, CI/CD pipelines, or automated workflows
- Get quick answers - One-off queries without starting an interactive session
- Process output programmatically - Pipe to files, parse JSON, or chain with other commands
- Bypass trust prompts - Work in trusted directories without manual confirmation
- Integrate with other tools - Combine Claude with existing command-line workflows
Security Considerations
⚠️ Warning: The -p flag bypasses the workspace trust dialog. This means:
- Claude will have access to tools without prompting for permission
- Only use this in directories you trust
- Be cautious when running in directories with sensitive data
- Consider using
--tools ""to disable all tools if you only need text generation
Advanced Usage
Streaming JSON Output
claude -p --output-format stream-json "Explain machine learning" | jq -r '.content'
Fallback Model (when primary is overloaded)
claude -p --fallback-model haiku "Quick question about Python syntax"
With MCP Servers
claude -p --mcp-config ./mcp-config.json "Query the database for user stats"
Structured Output with JSON Schema
claude -p --json-schema '{"type":"object","properties":{"name":{"type":"string"},"age":{"type":"number"}},"required":["name","age"]}' "Extract person info: John is 30 years old"
Tips and Best Practices
- Quote your prompts: Always use quotes around prompts to handle spaces and special characters
- Use specific models: Specify
--modelfor consistent behavior (e.g.,--model sonnetfor faster responses) - Set budget limits: Use
--max-budget-usdto prevent unexpected API costs - Disable tools when not needed: Use
--tools ""for pure text generation to improve speed and reduce costs - Capture output: Redirect output to files or variables for further processing
- Check exit codes: The command returns 0 on success, non-zero on errors
Troubleshooting
Command not found
Ensure Claude CLI is installed and in your PATH:
which claude
Permission errors
Make sure you're in a directory you trust, or the -p flag won't help with file access permissions.
API rate limits
Use --max-budget-usd to control spending, or wait if you hit rate limits.
Related Commands
claude --help: View all available optionsclaude --version: Check installed versionclaude doctor: Check CLI health and configurationclaude setup-token: Configure authentication
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: jeffpignataro
- Source: jeffpignataro/claude-oauth-skill
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.