mirror of
https://github.com/tradecatlabs/vibe-coding-cn.git
synced 2026-08-26 09:08:29 +00:00
docs: sync en/ with zh/ - add missing translations
- Add headless-cli skill (SKILL.md + references) - Add Hard Constraints.md (强前置条件约束) - Add Code Review.md (审查代码) - Translated using Gemini CLI headless mode
This commit is contained in:
@@ -0,0 +1,176 @@
|
||||
```
|
||||
name: headless-cli
|
||||
description: "Headless Mode AI CLI Calling Skill: Supports non-interactive batch calling of Gemini/Claude/Codex CLIs, including YOLO mode and safe mode. Used for scenarios like batch translation, code review, multi-model orchestration, etc."
|
||||
---
|
||||
|
||||
# Headless CLI Skill
|
||||
|
||||
Non-interactive batch calling of AI CLI tools, supporting stdin/stdout pipes to achieve automated workflows.
|
||||
|
||||
## When to Use This Skill
|
||||
|
||||
Trigger conditions:
|
||||
- Need to process files in batches (translate, review, format)
|
||||
- Need to call AI models in scripts
|
||||
- Need to chain/parallelize multiple models
|
||||
- Need unattended AI task execution
|
||||
|
||||
## Not For / Boundaries
|
||||
|
||||
Not applicable for:
|
||||
- Scenarios requiring interactive conversation
|
||||
- Tasks requiring real-time feedback
|
||||
- Sensitive operations (YOLO mode requires caution)
|
||||
|
||||
Required inputs:
|
||||
- Corresponding CLI tools installed
|
||||
- Identity authentication completed
|
||||
- Network proxy configuration (if needed)
|
||||
|
||||
## Quick Reference
|
||||
|
||||
### 🔴 YOLO Mode (Full permissions, skips confirmation)
|
||||
|
||||
**Codex CLI**
|
||||
```bash
|
||||
# --yolo is an alias for --dangerously-bypass-approvals-and-sandbox
|
||||
alias c='codex --enable web_search_request -m gpt-5.1-codex-max -c model_reasoning_effort="high" --yolo'
|
||||
```
|
||||
|
||||
**Claude Code**
|
||||
```bash
|
||||
alias cc='claude --dangerously-skip-permissions'
|
||||
```
|
||||
|
||||
**Gemini CLI**
|
||||
```bash
|
||||
# --yolo or --approval-mode yolo
|
||||
alias g='gemini --yolo'
|
||||
```
|
||||
|
||||
### 🟡 Full-Auto Mode (Recommended automation method)
|
||||
|
||||
**Codex CLI**
|
||||
```bash
|
||||
# workspace-write sandbox + approval only on failure
|
||||
codex --full-auto "Your prompt"
|
||||
```
|
||||
|
||||
**Gemini CLI**
|
||||
```bash
|
||||
# Automatically approve edit tools
|
||||
gemini --approval-mode auto_edit "Your prompt"
|
||||
```
|
||||
|
||||
### 🟢 Safe Mode (Headless but with limitations)
|
||||
|
||||
**Gemini CLI (Disable tool calls)**
|
||||
```bash
|
||||
cat input.md | gemini -p "prompt" --output-format text --allowed-tools '' > output.md
|
||||
```
|
||||
|
||||
**Claude Code (Print Mode)**
|
||||
```bash
|
||||
cat input.md | claude -p "prompt" --output-format text > output.md
|
||||
```
|
||||
|
||||
**Codex CLI (Non-interactive execution)**
|
||||
```bash
|
||||
codex exec "prompt" --json -o result.txt
|
||||
```
|
||||
|
||||
### 📋 Common Command Templates
|
||||
|
||||
**Batch Translation**
|
||||
```bash
|
||||
# Set proxy (if needed)
|
||||
export http_proxy=http://127.0.0.1:9910
|
||||
export https_proxy=http://127.0.0.1:9910
|
||||
|
||||
# Gemini Translation
|
||||
cat zh.md | gemini -p "Translate to English. Keep code/links unchanged." \
|
||||
--output-format text --allowed-tools '' > en.md
|
||||
```
|
||||
|
||||
**Code Review**
|
||||
```bash
|
||||
cat code.py | claude --dangerously-skip-permissions -p \
|
||||
"Review this code for bugs and security issues. Output markdown." > review.md
|
||||
```
|
||||
|
||||
**Multi-Model Orchestration**
|
||||
```bash
|
||||
# Model A generates → Model B reviews
|
||||
cat spec.md | gemini -p "Generate code" --output-format text | \
|
||||
claude -p "Review and improve this code" --output-format text > result.md
|
||||
```
|
||||
|
||||
### ⚙️ Key Parameter Comparison Table
|
||||
|
||||
| Feature | Gemini CLI | Claude Code | Codex CLI |
|
||||
|:---|:---|:---|:---|
|
||||
| YOLO Mode | `--yolo` | `--dangerously-skip-permissions` | `--yolo` |
|
||||
| Specify Model | `-m <model>` | `--model <model>` | `-m <model>` |
|
||||
| Non-interactive | `-p "prompt"` | `-p "prompt"` | `exec "prompt"` |
|
||||
| Output Format | `--output-format text` | `--output-format text` | `--json` |
|
||||
| Disable Tools | `--allowed-tools ''` | `--disallowedTools` | N/A |
|
||||
| Continue Conversation | N/A | `-c` / `--continue` | `resume --last` |
|
||||
|
||||
## Examples
|
||||
|
||||
### Example 1: Batch Translating Documents
|
||||
|
||||
**Input**: Chinese Markdown file
|
||||
**Steps**:
|
||||
```bash
|
||||
export http_proxy=http://127.0.0.1:9910
|
||||
export https_proxy=http://127.0.0.1:9910
|
||||
|
||||
for f in docs/*.md; do
|
||||
cat "$f" | timeout 120 gemini -p \
|
||||
"Translate to English. Keep code fences unchanged." \
|
||||
--output-format text --allowed-tools '' 2>/dev/null > "en_$(basename $f)"
|
||||
done
|
||||
```
|
||||
**Expected output**: Translated English file
|
||||
|
||||
### Example 2: Code Review Pipeline
|
||||
|
||||
**Input**: Python code file
|
||||
**Steps**:
|
||||
```bash
|
||||
cat src/*.py | claude --dangerously-skip-permissions -p \
|
||||
"Review for: 1) Bugs 2) Security 3) Performance. Output markdown table." > review.md
|
||||
```
|
||||
**Expected output**: Markdown formatted review report
|
||||
|
||||
### Example 3: Multi-Model Comparison and Verification
|
||||
|
||||
**Input**: Technical question
|
||||
**Steps**:
|
||||
```bash
|
||||
question="How to implement rate limiting in Python?"
|
||||
|
||||
echo "$question" | gemini -p "$question" --output-format text > gemini_answer.md
|
||||
echo "$question" | claude -p "$question" --output-format text > claude_answer.md
|
||||
|
||||
# Compare the two answers
|
||||
diff gemini_answer.md claude_answer.md
|
||||
```
|
||||
**Expected output**: Comparison of answers from two models
|
||||
|
||||
## References
|
||||
|
||||
- `references/gemini-cli.md` - Gemini CLI complete parameters
|
||||
- `references/claude-cli.md` - Claude Code CLI parameters
|
||||
- `references/codex-cli.md` - Codex CLI parameters
|
||||
- [Gemini CLI Official Documentation](https://geminicli.com/docs/)
|
||||
- [Claude Code Official Documentation](https://docs.anthropic.com/en/docs/claude-code/)
|
||||
- [Codex CLI Official Documentation](https://developers.openai.com/codex/cli/reference)
|
||||
|
||||
## Maintenance
|
||||
|
||||
- Source: Official CLI documentation for each
|
||||
- Updated: 2025-12-19
|
||||
- Limitations: Requires network connection and valid authentication; YOLO mode has security risks
|
||||
```
|
||||
@@ -0,0 +1,117 @@
|
||||
Here is the English translation of the Markdown document:
|
||||
|
||||
# Claude Code CLI Parameter Reference
|
||||
|
||||
> Source: [Official Documentation](https://docs.anthropic.com/en/docs/claude-code/cli-reference)
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install -g @anthropic-ai/claude-code
|
||||
```
|
||||
|
||||
## Authentication
|
||||
|
||||
Requires an Anthropic API Key or Claude Pro/Max subscription:
|
||||
```bash
|
||||
export ANTHROPIC_API_KEY="YOUR_API_KEY"
|
||||
```
|
||||
|
||||
## Core Commands
|
||||
|
||||
| Command | Description | Example |
|
||||
|:---|:---|:---|
|
||||
| `claude` | Starts an interactive REPL | `claude` |
|
||||
| `claude "query"` | Starts with an initial prompt | `claude "explain this"` |
|
||||
| `claude -p "query"` | Print mode, exits after execution | `claude -p "review code"` |
|
||||
| `claude -c` | Continues the most recent conversation | `claude -c` |
|
||||
| `claude -c -p "query"` | Continues conversation (Print mode) | `claude -c -p "run tests"` |
|
||||
| `claude -r "id" "query"` | Resumes a specified session | `claude -r "abc123" "continue"` |
|
||||
| `claude update` | Updates to the latest version | `claude update` |
|
||||
| `claude mcp` | Configures the MCP server | `claude mcp add server` |
|
||||
|
||||
## CLI Parameters
|
||||
|
||||
| Parameter | Description | Example |
|
||||
|:---|:---|:---|
|
||||
| `--model` | Specifies the model | `--model claude-sonnet-4` |
|
||||
| `--output-format` | Output format: `text`/`json`/`stream-json` | `--output-format json` |
|
||||
| `--max-turns` | Limits the number of conversation turns | `--max-turns 3` |
|
||||
| `--dangerously-skip-permissions` | Skips all permission confirmations (YOLO) | See below |
|
||||
| `--allowedTools` | List of allowed tools | `--allowedTools "Write" "Bash(git *)"` |
|
||||
| `--disallowedTools` | List of disallowed tools | `--disallowedTools "Bash(rm *)"` |
|
||||
| `--add-dir` | Adds additional working directories | `--add-dir ./apps ./lib` |
|
||||
| `--verbose` | Enables detailed logs | `--verbose` |
|
||||
| `--continue` | Continues the recent conversation | `--continue` |
|
||||
| `--resume` | Resumes a specified session | `--resume abc123` |
|
||||
|
||||
## Available Models
|
||||
|
||||
- `claude-sonnet-4` - Balanced model (default)
|
||||
- `claude-opus-4` - Most powerful model
|
||||
- `claude-opus-4.5` - Latest and most powerful
|
||||
|
||||
## Headless Mode Usage
|
||||
|
||||
```bash
|
||||
# Print mode (non-interactive, exits after execution)
|
||||
claude -p "review this code" --output-format text
|
||||
|
||||
# Piped input
|
||||
cat input.txt | claude -p "explain these errors"
|
||||
|
||||
# YOLO mode (skips all permission confirmations)
|
||||
claude --dangerously-skip-permissions "Your prompt"
|
||||
|
||||
# Alias setup
|
||||
alias cc='claude --dangerously-skip-permissions'
|
||||
|
||||
# Continue conversation + Print mode (suitable for scripts)
|
||||
claude -c -p "show progress"
|
||||
```
|
||||
|
||||
## Interactive Commands (Slash Commands)
|
||||
|
||||
| Command | Description |
|
||||
|:---|:---|
|
||||
| `/help` | Displays all commands |
|
||||
| `/config` | Configures settings |
|
||||
| `/allowed-tools` | Configures tool permissions |
|
||||
| `/mcp` | Manages MCP servers |
|
||||
| `/vim` | Enables vim editing mode |
|
||||
|
||||
## Configuration Files
|
||||
|
||||
- User settings: `~/.claude/settings.json`
|
||||
- Project settings: `.claude/settings.json`
|
||||
- Local settings: `.claude/settings.local.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"model": "claude-sonnet-4",
|
||||
"permissions": {
|
||||
"allowedTools": ["Read", "Write", "Bash(git *)"],
|
||||
"deny": ["Read(./.env)", "Bash(rm *)"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Context Files (CLAUDE.md)
|
||||
|
||||
- Global: `~/.claude/CLAUDE.md`
|
||||
- Project: `./CLAUDE.md`
|
||||
- Subdirectory: Component-specific instructions
|
||||
|
||||
## Deep Thinking Trigger Words
|
||||
|
||||
Increasing intensity:
|
||||
- `think` - Basic thinking
|
||||
- `think hard` - Deep thinking
|
||||
- `think harder` - Deeper thinking
|
||||
- `ultrathink` - Deepest thinking
|
||||
|
||||
## Common Issues
|
||||
|
||||
1. **Permission pop-ups**: Use `--dangerously-skip-permissions`
|
||||
2. **Context too long**: Use `/compact` or `/clear`
|
||||
3. **Reverting changes**: Use `/rewind`
|
||||
@@ -0,0 +1,125 @@
|
||||
```markdown
|
||||
# Codex CLI Parameter Reference
|
||||
|
||||
> Source: [Official Documentation](https://developers.openai.com/codex/cli/reference)
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install -g @openai/codex
|
||||
```
|
||||
|
||||
## Authentication
|
||||
|
||||
```bash
|
||||
# Method 1: Browser OAuth (ChatGPT account)
|
||||
codex login
|
||||
|
||||
# Method 2: API Key
|
||||
printenv OPENAI_API_KEY | codex login --with-api-key
|
||||
|
||||
# Check login status
|
||||
codex login status
|
||||
```
|
||||
|
||||
## Core Commands
|
||||
|
||||
| Command | Description | Example |
|
||||
|:---|:---|:---|
|
||||
| `codex` | Starts interactive TUI | `codex` |
|
||||
| `codex "prompt"` | Starts with a prompt | `codex "explain this"` |
|
||||
| `codex exec` / `codex e` | Non-interactive mode | `codex exec "fix bugs"` |
|
||||
| `codex resume` | Resumes session | `codex resume --last` |
|
||||
| `codex apply` / `codex a` | Applies diff from Cloud task | `codex apply TASK_ID` |
|
||||
| `codex mcp` | Manages MCP server | `codex mcp add server` |
|
||||
| `codex completion` | Generates shell completion | `codex completion zsh` |
|
||||
|
||||
## Global Parameters
|
||||
|
||||
| Parameter | Description | Example |
|
||||
|:---|:---|:---|
|
||||
| `--model, -m` | Specifies model | `-m gpt-5-codex` |
|
||||
| `--sandbox, -s` | Sandbox policy: `read-only`/`workspace-write`/`danger-full-access` | `-s workspace-write` |
|
||||
| `--ask-for-approval, -a` | Approval mode: `untrusted`/`on-failure`/`on-request`/`never` | `-a on-failure` |
|
||||
| `--full-auto` | Automatic preset (workspace-write + on-failure) | `--full-auto` |
|
||||
| `--dangerously-bypass-approvals-and-sandbox` / `--yolo` | Bypasses all approvals and sandbox | `--yolo` |
|
||||
| `--search` | Enables web search | `--search` |
|
||||
| `--add-dir` | Adds extra write directory | `--add-dir ./other` |
|
||||
| `--enable` | Enables feature flag | `--enable web_search_request` |
|
||||
| `--disable` | Disables feature flag | `--disable feature_name` |
|
||||
| `--config, -c` | Configuration override | `-c model_reasoning_effort="high"` |
|
||||
| `--image, -i` | Attaches image | `-i image.png` |
|
||||
| `--cd, -C` | Sets working directory | `-C /path/to/project` |
|
||||
| `--profile, -p` | Profile configuration | `-p my-profile` |
|
||||
| `--oss` | Uses local open-source model (Ollama) | `--oss` |
|
||||
|
||||
## `codex exec` Specific Parameters
|
||||
|
||||
| Parameter | Description | Example |
|
||||
|:---|:---|:---|
|
||||
| `--json` | Outputs JSONL format | `--json` |
|
||||
| `--output-last-message, -o` | Saves final message to file | `-o result.txt` |
|
||||
| `--output-schema` | JSON Schema validation output | `--output-schema schema.json` |
|
||||
| `--color` | Color output: `always`/`never`/`auto` | `--color never` |
|
||||
| `--skip-git-repo-check` | Allows running in non-Git directories | `--skip-git-repo-check` |
|
||||
|
||||
## Available Models
|
||||
|
||||
- `gpt-5-codex` - Standard model
|
||||
- `gpt-5.1-codex` - Enhanced version
|
||||
- `gpt-5.1-codex-max` - Strongest model
|
||||
|
||||
## Reasoning Strength Configuration
|
||||
|
||||
```bash
|
||||
-c model_reasoning_effort="low" # Fast
|
||||
-c model_reasoning_effort="medium" # Balanced
|
||||
-c model_reasoning_effort="high" # Deep
|
||||
```
|
||||
|
||||
## Headless Mode Usage
|
||||
|
||||
```bash
|
||||
# Non-interactive execution
|
||||
codex exec "fix all linting errors"
|
||||
|
||||
# Piped input
|
||||
echo "explain this error" | codex exec -
|
||||
|
||||
# YOLO mode (skips all confirmations and sandbox)
|
||||
codex --yolo "Your prompt"
|
||||
|
||||
# Or full syntax
|
||||
codex --dangerously-bypass-approvals-and-sandbox "Your prompt"
|
||||
|
||||
# full-auto mode (recommended automated approach)
|
||||
codex --full-auto "Your prompt"
|
||||
|
||||
# Full YOLO config alias
|
||||
alias c='codex --enable web_search_request -m gpt-5.1-codex-max -c model_reasoning_effort="high" --yolo'
|
||||
|
||||
# Resume last session
|
||||
codex resume --last
|
||||
codex exec resume --last "continue"
|
||||
```
|
||||
|
||||
## Configuration File
|
||||
|
||||
Configuration is stored in `~/.codex/config.toml`:
|
||||
|
||||
```toml
|
||||
model = "gpt-5-codex"
|
||||
sandbox = "workspace-write"
|
||||
ask_for_approval = "on-failure"
|
||||
|
||||
[features]
|
||||
web_search_request = true
|
||||
```
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
||||
1. **Approval pop-ups**: Use `--yolo` or `--full-auto`
|
||||
2. **Internet connection required**: Use `--search` or `--enable web_search_request`
|
||||
3. **Insufficient reasoning depth**: Use `-c model_reasoning_effort="high"`
|
||||
4. **Non-Git directory**: Use `--skip-git-repo-check`
|
||||
```
|
||||
@@ -0,0 +1,83 @@
|
||||
Here's the English translation of the provided Markdown document:
|
||||
|
||||
# Gemini CLI Parameter Reference
|
||||
|
||||
> Source: [Official Documentation](https://geminicli.com/docs/get-started/configuration/)
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install -g @anthropic-ai/gemini-cli
|
||||
```
|
||||
|
||||
## Authentication
|
||||
|
||||
The first run will guide you through Google account login, or you can set environment variables:
|
||||
```bash
|
||||
export GEMINI_API_KEY="YOUR_API_KEY"
|
||||
```
|
||||
|
||||
## Core Command Line Parameters
|
||||
|
||||
| Parameter | Description | Example |
|
||||
|:---|:---|:---|
|
||||
| `--model <model>` | Specify model | `--model gemini-2.5-flash` |
|
||||
| `--yolo` | YOLO mode, automatically approve all tool calls | `gemini --yolo` |
|
||||
| `--approval-mode <mode>` | Approval mode: `default`/`auto_edit`/`yolo` | `--approval-mode auto_edit` |
|
||||
| `--allowed-tools <tools>` | List of allowed tools (comma separated) | `--allowed-tools ''` (disable all) |
|
||||
| `--output-format <format>` | Output format: `text`/`json`/`stream-json` | `--output-format text` |
|
||||
| `--sandbox` / `-s` | Enable sandbox mode | `gemini -s` |
|
||||
| `--prompt <prompt>` / `-p` | Non-interactive mode, pass prompt directly | `gemini -p "query"` |
|
||||
| `--prompt-interactive <prompt>` / `-i` | Interactive mode with initial prompt | `gemini -i "explain"` |
|
||||
| `--debug` / `-d` | Enable debug mode | `gemini -d` |
|
||||
|
||||
## Available Models
|
||||
|
||||
- `gemini-2.5-flash` - Fast model
|
||||
- `gemini-2.5-pro` - Advanced model
|
||||
- `gemini-3-flash-preview` - Latest Flash
|
||||
- `gemini-3-pro-preview` - Latest Pro
|
||||
|
||||
## Headless Mode Usage
|
||||
|
||||
```bash
|
||||
# Basic headless call (piped input)
|
||||
cat input.txt | gemini -p "Your prompt" --output-format text
|
||||
|
||||
# Disable tool calls (plain text output)
|
||||
cat input.txt | gemini -p "Your prompt" --output-format text --allowed-tools ''
|
||||
|
||||
# YOLO mode (skip all confirmations)
|
||||
gemini --yolo "Your prompt"
|
||||
|
||||
# Or use approval-mode
|
||||
gemini --approval-mode yolo "Your prompt"
|
||||
```
|
||||
|
||||
## Configuration File
|
||||
|
||||
Configuration is stored in `~/.gemini/settings.json` or project `.gemini/settings.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"security": {
|
||||
"disableYoloMode": false
|
||||
},
|
||||
"model": {
|
||||
"name": "gemini-2.5-flash"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Proxy Configuration
|
||||
|
||||
```bash
|
||||
export http_proxy=http://127.0.0.1:9910
|
||||
export https_proxy=http://127.0.0.1:9910
|
||||
```
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
||||
1. **MCP initialization is slow**: Use `--allowed-tools ''` to skip.
|
||||
2. **Timeout**: Use the `timeout` command wrapper.
|
||||
3. **Output includes logs**: Redirect stderr `2>/dev/null`.
|
||||
@@ -0,0 +1,17 @@
|
||||
```markdown
|
||||
# Headless CLI References
|
||||
|
||||
> ⚠️ CLI parameters may change with version updates, please refer to the official documentation.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [gemini-cli.md](./gemini-cli.md) - Gemini CLI Parameters
|
||||
- [claude-cli.md](./claude-cli.md) - Claude Code CLI Parameters
|
||||
- [codex-cli.md](./codex-cli.md) - Codex CLI Parameters
|
||||
|
||||
## Official Documentation
|
||||
|
||||
- [Gemini CLI](https://github.com/google-gemini/gemini-cli)
|
||||
- [Claude Code](https://docs.anthropic.com/en/docs/claude-code)
|
||||
- [Codex CLI](https://github.com/openai/codex)
|
||||
```
|
||||
Reference in New Issue
Block a user