claude-code-headless
以無頭 CLI 模式執行 Claude Code
こちらからも入手できます: 0xDarkMatter
Claude Code 無頭模式可從 shell 腳本與 CI/CD 管線進行程式化執行。本技能提供非互動式自動化的文件與範例,並輸出結構化 JSON。
スキルZIPをダウンロード
Claudeでアップロード
設定 → 機能 → スキル → スキルをアップロードへ移動
オンにして利用開始
テストする
「claude-code-headless」を使用しています。 以無頭模式執行 Claude 來分析檔案
期待される結果:
- Claude 回傳包含結果文字、session ID、成本與耗時的結構化 JSON
- session ID 可用於延續多回合流程的對話
- 退出碼表示成功 (0) 或錯誤 (1/2) 以供腳本處理
セキュリティ監査
安全This is a pure documentation skill containing only markdown files that document Claude Code CLI usage. All static findings are FALSE POSITIVES because the 'external_commands' patterns are documentation examples in markdown code blocks, not actual executable code. The skill contains no scripts, no file operations, no network calls, and no credential access. Shell constructs like $(...) are examples showing how to parse Claude Code JSON output, not malicious command execution.
リスク要因
⚙️ 外部コマンド (211)
🔑 環境変数 (9)
📁 ファイルシステムへのアクセス (2)
🌐 ネットワークアクセス (3)
品質スコア
作れるもの
CI/CD 管線審查
在 GitHub Actions、GitLab CI 或 Jenkins 管線中自動化程式碼審查
腳本化自動化
建立 shell 腳本以進行批次處理與重複性任務
自動化稽核
以受限工具存取方式程式化執行安全掃描
これらのプロンプトを試す
claude -p "Explain this code" --output-format json
claude -p "Analyze codebase" --allowedTools "Read,Grep,Glob" --disallowedTools "Write,Edit,Bash"
claude -p "Start analysis" --output-format json | jq -r '.session_id' then claude --resume "$session" "Continue analysis"
claude -p "Review PR diff" --permission-mode acceptEdits --output-format json --append-system-prompt "Focus on security"
ベストプラクティス
- 在腳本中使用 --output-format json 以確保可可靠的程式化解析
- 使用 --allowedTools 與 --disallowedTools 限制工具存取以提升安全性
- 明確處理 session ID 與錯誤以強化自動化的穩定性
回避
- 在不受信任的情境下使用無頭模式且不限制工具
- 在自動化腳本中忽略退出碼與錯誤回應
- 在腳本中硬編碼 API 金鑰而非使用環境變數