Token导航 LogoToken导航

Agent Skill · AI 工具

claude-headless-mode(Claude headless mode 命令行)

claude-headless-mode 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

claude-headless-mode 是AI 工具类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为接触敏感数据;许可证为 MIT,第三方扫描已通过,按安装量在AI 工具类的 2,536 个 Skill 里排第 1,018。

总安装 1,327周安装 57GitHub Stars 37下载 465核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:claude-headless-mode(Claude headless mode 命令行)
来源仓库:https://github.com/majesticlabs-dev/majestic-marketplace
仓库路径:skills/claude-headless-mode
安装命令:
npx skills add https://github.com/majesticlabs-dev/majestic-marketplace --skill claude-headless-mode
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/majesticlabs-dev/majestic-marketplace --skill claude-headless-mode

这个 Skill 是做什么的

AI 工具类 Skill 用来扩展助手本身的能力,例如接模型、接检索、接外部服务。

支持非交互式执行 Claude 命令于脚本与 CI 环境。适合批量处理文件摘要与自动化代码审查任务。使用时需指定 -p 参数并选择 text 或 json 输出格式。涉及敏感信息时应避免明文打印至日志流。claude-headless-mode 属于AI 工具类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/claude-headless-mode

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/majesticlabs-dev/majestic-marketplace --skill…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要接触敏感数据,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

claude-headless-mode 怎么安装?

在终端执行 npx skills add https://github.com/majesticlabs-dev/majestic-marketplace --skill claude-hea…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

claude-headless-mode 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

claude-headless-mode 需要什么权限?

权限级别是接触敏感数据。该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

claude-headless-mode 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

claude-headless-mode 用的人多吗?

公开数据是累计安装 1,327 次,近一周安装 57 次,下载 465 次,GitHub 37 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

claude-headless-mode 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 3 个目录同时收录,说明这个 Skill 流传比较广。
  • 许可证明确为 MIT,商用和分发边界好判断。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 需要接触敏感数据,装到常用环境前要先评估影响面。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理AI 工具类任务、又不想每次都手写提示词的人。
  • 需要许可证清楚、并且有第三方扫描结果的团队项目。

不太适合

  • 环境里有大量密钥、凭证,不方便给第三方 Skill 读取的人。
  • 需要厂商级技术支持和 SLA 的生产系统。

AI 工具类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
executing-plans

执行计划 · Codex、Claude

1,515,336173,110只读MIT通过
verification-before-completion

完成前的验证 · Codex、Claude

1,319,472173,121权限未标注MIT通过
subagent-driven-development

子 Agent 驱动开发 · Codex、Claude

1,312,416173,138只读MIT通过
copy-editing

复制编辑 · Codex、Claude

1,209,57625,632只读MIT通过
paywall-upgrade-cro

付费专区升级 cro · Codex、Claude

1,030,17625,617只读MIT通过
claude-headless-mode

Claude headless mode 命令行 · 本页

1,32737接触敏感数据MIT通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Claude Headless Mode

Use claude -p (or --print) for non-interactive execution in scripts, CI, and automation.

Basic Usage

# Simple prompt
claude -p "Summarize this repo"

# With file input
claude -p "Review this code" < file.py

# Pipe output
claude -p "List all functions" | grep "def "

Output Formats

FormatFlagUse Case
Text--output-format textHuman-readable (default)
JSON--output-format jsonSingle JSON result
Stream JSON--output-format stream-json --verboseReal-time streaming

Text Output (Default)

claude -p "What is 2+2?"
# Output: 4

JSON Output

claude -p "What is 2+2?" --output-format json

Returns wrapper with metadata:

{
  "type": "result",
  "subtype": "success",
  "result": "4",
  "duration_ms": 1234,
  "total_cost_usd": 0.01,
  "session_id": "...",
  "structured_output": null
}

Extract just the result:

claude -p "What is 2+2?" --output-format json | jq -r '.result'

Stream JSON Output

claude -p "Long analysis" --output-format stream-json --verbose
  • Streams newline-delimited JSON as execution progresses
  • Shows tool calls, messages, progress in real-time
  • Final line contains the result
  • Requires --verbose flag

Extract final result:

claude -p "Analyze code" --output-format stream-json --verbose \
  | tee /dev/stderr \
  | tail -1 \
  | jq -r '.result'

Structured Output with JSON Schema

Force Claude to return data matching a specific schema:

claude -p "Extract function names from auth.py" \
  --output-format json \
  --json-schema '{
    "type": "object",
    "properties": {
      "functions": { "type": "array", "items": { "type": "string" } }
    },
    "required": ["functions"]
  }'

Result appears in structured_output field:

{
  "result": "...",
  "structured_output": {
    "functions": ["login", "logout", "verify_token"]
  }
}

Schema Examples

Simple object:

{
  "type": "object",
  "properties": {
    "answer": { "type": "integer" }
  },
  "required": ["answer"]
}

Task result (success/failure):

{
  "type": "object",
  "properties": {
    "status": { "type": "string", "enum": ["success", "failure"] },
    "summary": { "type": "string" },
    "files_changed": { "type": "array", "items": { "type": "string" } },
    "error_category": { "type": "string" },
    "suggestion": { "type": "string" }
  },
  "required": ["status", "summary"]
}

Extract from schema result:

OUTPUT=$(claude -p "$PROMPT" --output-format json --json-schema "$SCHEMA")
STATUS=$(echo "$OUTPUT" | jq -r '.structured_output.status')
SUMMARY=$(echo "$OUTPUT" | jq -r '.structured_output.summary')

Common Options

OptionDescription
-p, --printHeadless mode (required)
--output-formattext, json, stream-json
--json-schemaEnforce output schema
--verboseRequired for stream-json
--modelSelect model (sonnet, opus, haiku)
--max-turnsLimit agentic turns
--permission-modebypassPermissions, plan, etc.
--allowedToolsRestrict available tools

Permission Modes

# Skip all permission prompts (trusted environments only)
claude -p "Fix all linting errors" --permission-mode bypassPermissions

# Plan mode (read-only exploration)
claude -p "Analyze architecture" --permission-mode plan

Examples

CI/CD Integration

# Run tests and get structured result
RESULT=$(claude -p "Run tests and report results" \
  --output-format json \
  --json-schema '{"type":"object","properties":{"passed":{"type":"boolean"},"failures":{"type":"array","items":{"type":"string"}}},"required":["passed"]}')

if [ "$(echo $RESULT | jq '.structured_output.passed')" = "true" ]; then
  echo "Tests passed"
else
  echo "Tests failed"
  exit 1
fi

Batch Processing

for file in src/*.py; do
  claude -p "Review $file for security issues" \
    --output-format json \
    --json-schema '{"type":"object","properties":{"issues":{"type":"array"}},"required":["issues"]}' \
    | jq ".structured_output.issues"
done

Fresh Context Task Execution

# Each invocation is independent (no conversation history)
claude -p "Task 1: Create migration" --output-format json
claude -p "Task 2: Add model" --output-format json
claude -p "Task 3: Write tests" --output-format json

Task Coordination

Share TaskList across headless invocations using CLAUDE_CODE_TASK_LIST_ID.

Environment Variable

# All invocations share the same TaskList
export CLAUDE_CODE_TASK_LIST_ID="my-project"
claude -p "Use TaskCreate to add: Setup database"
claude -p "Use TaskCreate to add: Write migrations"
claude -p "Use TaskList to show all tasks"  # Shows both tasks

Pattern: Orchestrator + Workers

TASK_LIST_ID="epic-$(date +%Y%m%d)"
export CLAUDE_CODE_TASK_LIST_ID="$TASK_LIST_ID"

# Orchestrator creates tasks
claude -p "Use TaskCreate for each: Task 1, Task 2, Task 3"

# Workers execute (each sees shared TaskList)
for task_id in 1 2 3; do
  claude -p "Use TaskUpdate to mark task #$task_id as in_progress, implement it, then mark completed"
done

# Check final state
claude -p "Use TaskList to show status"

Task Tools

ToolPurpose
TaskCreateCreate new task with subject, description
TaskListList all tasks with status
TaskUpdateUpdate task status (in_progress, completed) or add blockedBy
TaskGetGet full details of a specific task

Dependencies

# Task 2 depends on Task 1
claude -p "Use TaskUpdate on task #2 to set blockedBy: [1]"

Tasks persist to ~/.claude/tasks/ and survive session restarts.

Notes

  • Each -p invocation starts fresh (no context from previous runs)
  • Use --output-format json for programmatic parsing
  • structured_output field contains schema-validated data
  • result field contains raw text response
  • Stream JSON requires --verbose flag
  • Cost info available in JSON output: total_cost_usd

平台分布

Antigravity

31.55%
按下载量换算147

Claude Code

20.76%
按下载量换算97

OpenCode

15.57%
按下载量换算72

Gemini CLI

11.22%
按下载量换算52

windsurf

8.39%
按下载量换算39

github-copilot

3.54%
按下载量换算16

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

接触敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

继续浏览同类 Skills