20251120 - 终端中的人工智能指南 - ai-in-the-terminaldocs14-cheat-sheet.md at main · theNetworkChuckai-in-the-terminal¶
- 分类:
Clippings - 创建:
2025-11-20 - 标签:
人工智能, 终端工具, 开发, 项目管理, Git
ai-in-the-terminal/docs/14-cheat-sheet.md at main · theNetworkChuck/ai-in-the-terminal¶
摘要 (Summary)¶
此页面是关于如何在终端中使用人工智能工具的指南,涵盖了安装命令、启动命令、会话命令、项目设置、上下文更新、文件操作、Git集成和常见工作流程等主题。
要点 (Key Facts)¶
- 安装 Gemini CLI 和 Claude Code 的命令。
- 启动命令和会话命令的示例。
- 项目设置和上下文管理的步骤。
- Git 集成和多终端工作流程的操作。
- 错误排除和紧急命令。
正文 (Content)¶
Open in github.dev Open in a new github.dev tab Open in codespace
and
Initial commit: AI in the Terminal companion guide
8710b0b ·
Quick reference for all AI terminal tools covered in the video.
Installation Commands¶
Gemini CLI¶
# Linux/macOS/WSL (npm)
npm install -g @google/generative-ai-cli
# With sudo (if permission error)
sudo npm install -g @google/generative-ai-cli
# macOS (Homebrew)
brew install gemini-cli
Claude Code¶
# All platforms (npm)
npm install -g @anthropic-ai/claude-code
# With sudo
sudo npm install -g @anthropic-ai/claude-code
opencode¶
# Installation (one command - from video)
curl -fsSL https://opencode.sh/install.sh | sh
# Reload shell
source ~/.bashrc
# or
source ~/.zshrc
Launch Commands¶
Basic Launch¶
gemini # Launch Gemini CLI
claude # Launch Claude Code
codex # Launch Codex
opencode # Launch opencode
# Claude Code
claude -r # Resume previous session
claude --dangerously-skip-permissions # Skip safety prompts
claude -r --dangerously-skip-permissions # Both flags combined
# Gemini CLI
gemini -p "your prompt here" # Headless mode (one-shot)
# opencode
opencode --model claude-sonnet-4 # Specify model
In-Session Commands¶
Gemini CLI¶
/init # Create gemini.md context file
/tools # Show available tools
/help # Show help
exit # Exit Gemini (or Ctrl+C)
Claude Code¶
Keyboard shortcuts:
Tab # Toggle thinking mode
Shift+Tab # Toggle planning mode
Ctrl+C # Interrupt/exit
Ctrl+O # View agent details (when agent running)
opencode¶
Project Setup¶
# Standard workflow
mkdir my-project
cd my-project
# Launch AI and create context
gemini
> /init
# Verify context file created
ls *.md
# Create project
mkdir my-project
cd my-project
# Initialize all three context files
# Terminal 1
gemini
> /init
# Terminal 2
claude
> /init
# Terminal 3
codex
> /init
# Sync context files
claude
> Sync claude.md to gemini.md and agents.md
# Let AI create it
> /init
# Manual creation
nano gemini.md # Edit manually
nano claude.md
nano agents.md
Update Context¶
View Context¶
# View file contents
cat gemini.md
cat claude.md
cat agents.md
# In Claude, check context usage
> /context
Agent Management¶
Deploy Agents¶
Multi-Agent Tasks¶
> /output-style # View available styles
> /output-style new # Create new style
> /output-style # Select active style
> /output-style new
# Then describe the style:
Name: my-expert
Description: You are an expert in [domain]...
File Operations¶
Create Files¶
# Ask AI to create
> Create a file named project-plan.md with [content]
# Manual creation
nano project-plan.md
Read Files¶
# AI reads files automatically when mentioned
> Read project-plan.md and summarize
# Reference with @
> Review @project-plan.md
Update Files¶
List Files¶
# Terminal command
ls
ls -la
# AI command
> What files are in this directory?
> Show me all markdown files
Git Integration¶
Initialize Repository¶
Regular Commits¶
# Using session-closer agent
> @script-session-closer run
# Agent automatically:
# - Summarizes session
# - Updates context files
# - Commits to git
Multi-Terminal Workflows¶
# Terminal 1: Claude
cd ~/my-project
claude
# Terminal 2: Gemini
cd ~/my-project
gemini
# Terminal 3: Codex
cd ~/my-project
codex
tmux (Advanced)¶
# Start tmux session
tmux new -s ai-work
# Create windows
Ctrl+B, C # New window
Ctrl+B, [0-9] # Switch to window N
Ctrl+B, " # Split horizontal
Ctrl+B, % # Split vertical
Model Management¶
# View available models
> /model
# Switch to specific model
> /model claude-sonnet-4
> /model grok-fast
> /model llama-3.2
Configuration¶
# Edit config file
nano ~/.config/opencode/opencode.jsonc
# Example config for local model
{
"model": "llama-3.2"
}
Authentication¶
Session Management¶
Advanced Techniques¶
Headless Mode¶
# Gemini one-shot command
gemini -p "Research ZFS performance and save to report.md"
# Claude with pipe
echo "Analyze this file" | claude
# Chain commands
gemini -p "Research topic" && claude -r
# Claude agent using Gemini
> @gemini-research search for latest Docker security updates
# Agent runs:
gemini -p "search for latest Docker security updates"
Obsidian Integration¶
Troubleshooting Commands¶
Permission Issues¶
# Reinstall with sudo
sudo npm install -g @google/generative-ai-cli
# Fix permissions
sudo chown -R $USER /usr/local/lib/node_modules
# Reload shell
source ~/.bashrc
source ~/.zshrc
# Verify installation
which gemini
which claude
which opencode
# Check PATH
echo $PATH
Clear Cache/Reset¶
# Claude Code
rm -rf ~/.config/claude-code
# Gemini CLI
rm -rf ~/.config/gemini-cli
# opencode
rm -rf ~/.config/opencode
Common Workflows¶
# Step 1: Research (Gemini)
gemini
> Research [topic] and compile findings
# Step 2: Write (Claude)
claude
> Read research.md and write comprehensive blog post
# Step 3: Review (Codex)
codex
> Review blog-post.md for accuracy and clarity
Project Kickoff¶
# Create project
mkdir project-name
cd project-name
# Initialize
gemini
> /init
> Help me plan this project: [description]
# Track with git
git init
git add .
git commit -m "Project initialized"
# Start
cd ~/current-project
claude
# Check status
> Where are we in the project?
# Work
> [Your tasks]
# End session
> @script-session-closer run
# Or manually:
git add .
git commit -m "Session: [summary]"
Quick Tips¶
Keyboard Shortcuts¶
Ctrl+C # Interrupt AI / Exit
Ctrl+D # Exit (alternative)
Tab # Toggle thinking (Claude)
Shift+Tab # Toggle planning (Claude)
Ctrl+O # Check agent status (Claude)
Speed Tips¶
# Use dangerous mode (when safe)
claude --dangerously-skip-permissions
# Use headless for quick tasks
gemini -p "quick question"
# Deploy agents for parallel work
> @agent1 task A, @agent2 task B
Organization Tips¶
# One directory per project
~/projects/project-a/
~/projects/project-b/
# Consistent context file naming
gemini.md, claude.md, agents.md
# Use git for everything
git commit regularly
Emergency Commands¶
# Find process ID
ps aux | grep gemini
ps aux | grep claude
# Kill it
kill -9 [PID]
# Or use Ctrl+C twice rapidly
Reset Everything¶
# Remove config directories
rm -rf ~/.config/gemini-cli
rm -rf ~/.config/claude-code
rm -rf ~/.config/opencode
# Reinstall
npm install -g @google/generative-ai-cli
npm install -g @anthropic-ai/claude-code
curl -fsSL https://opencode.sh/install.sh | sh
# Gemini CLI
https://ai.google.dev/gemini-api/docs/cli
# Claude Code
https://docs.anthropic.com/claude/docs/claude-code
# opencode
https://github.com/stackblitz-labs/opencode
# Codex
https://platform.openai.com/docs/tools/codex
Print this page for quick reference!