关于 llm-advisor
llm-advisor 是一项借助 Simon Willison 的 `llm` 命令行工具咨询其他 LLM 的 Agent 技能,面向需要调试、代码审查或设计决策第二意见的开发者。
主要功能
- 01通过 `llm` 命令行咨询模型
- 02将代码、差异和日志传入提示词
- 03带上下文继续对话
- 04比较多个模型的回答
适用场景
- 01咨询棘手问题的调试思路
- 02检查代码变更中的风险
- 03比较不同架构方案
- 04验证功能实施计划
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ ckorhonen/ claude-skills --skill llm-advisor安装后在 Claude Code 中输入/llm-advisor确认已加载。
详细介绍
LLM 顾问
使用 Simon Willison 的 llm CLI 咨询其他大模型,针对复杂问题获取第二意见、不同视角和专家建议。
何时使用此技能
主动使用(自主)
在以下情况下,无需他人请求即可主动使用此技能:
- 调试某个错误或问题超过 15 分钟
- 复杂调试,且根本原因不明确
- 架构决策,涉及重大权衡
- 规划复杂功能,需要验证
- 不熟悉的代码库/语言,需要指导
- 安全敏感代码(身份验证、加密、输入验证)
按需使用(用户请求)
在用户说出以下内容时使用:
- “就 X 询问 Gemini/GPT/Claude”
- “对此征求第二意见”
- “GPT 会如何看待这种方法?”
- “找另一个模型确认一下”
前置条件
安装
# Install llm CLI
brew install llm
# or
pip install llm
# Set up OpenAI API key
llm keys set openai
# Install Gemini plugin (optional)
llm install llm-gemini
llm keys set gemini
# Install Anthropic plugin (optional)
llm install llm-anthropic
llm keys set anthropic
验证设置
# Check available models
llm models
# Test a simple prompt
llm "Hello, what model are you?"
模型选择(截至 2026 年)
OpenAI 模型
| 用例 | 模型 | 命令 |
|---|---|---|
| 快速/低成本 | gpt-4o-mini | llm -m gpt-4o-mini "question" |
| 通用 | gpt-4.1 | llm -m gpt-4.1 "question" |
| 复杂推理 | o4-mini | llm -m o4-mini -o reasoning_effort=high "question" |
| 深度推理 | o3 | llm -m o3 "question" |
| 高端 | gpt-4.1 | llm -m gpt-4.1 "question" |
**注意:**运行
llm models,查看已安装的具体模型 ID。OpenAI 模型名称经常变化。截至 2026 年,gpt-4.1是旗舰 GPT,o3/o4-mini是推理模型。
Google Gemini 模型
| 用例 | 模型 | 命令 |
|---|---|---|
| 快速通用 | gemini-2.0-flash | llm -m gemini-2.0-flash "question" |
| 高级推理 | gemini-2.5-pro | llm -m gemini-2.5-pro "question" |
| 长上下文(1M+) | gemini-2.5-pro | llm -m gemini-2.5-pro "question" |
| 深度推理 | gemini-2.5-pro | llm -m gemini-2.5-pro -o thinking_budget=32000 "question" |
Anthropic Claude 模型
| 用例 | 模型 | 命令 |
|---|---|---|
| 快速/高性价比 | claude-haiku-4 | llm -m claude-haiku-4 "question" |
| 通用 | claude-sonnet-4-5 | llm -m claude-sonnet-4-5 "question" |
| 最高质量 | claude-opus-4-5 | llm -m claude-opus-4-5 "question" |
模型选择指南
- 快速提问:使用
gpt-4o-mini或gemini-2.0-flash - 一般建议:使用
gpt-4.1或claude-sonnet-4-5 - 复杂调试:使用
o4-mini -o reasoning_effort=high或gemini-2.5-pro -o thinking_budget=32000 - 代码审查:使用
gpt-4.1或claude-sonnet-4-5进行全面分析 - 架构/深度推理:使用
o3或claude-opus-4-5 - 长上下文(>100K 个 token):使用
gemini-2.5-pro(上下文窗口超过 1M)
命令参考
基本提示词
# Simple question
llm "What's the best way to handle rate limiting in a REST API?"
# With specific model
llm -m gpt-4.1 "Explain this error: <error message>"
# With system prompt
llm -s "You are a senior software architect" "Review this design: <design>"
管道输入
# Analyze code from file
cat src/auth.ts | llm -m gpt-4.1 "Review this authentication code for security issues"
# Analyze git diff
git diff | llm -m gpt-4.1 "Review these changes for bugs"
# Analyze error logs
cat error.log | llm -m gpt-4o-mini "What's causing these errors?"
选项
# Control reasoning effort (OpenAI o-series)
llm -m o4-mini -o reasoning_effort=high "Complex question"
llm -m o4-mini -o reasoning_effort=low "Simple question"
# Enable thinking mode (Gemini)
llm -m gemini-2.5-pro -o thinking_budget=32000 "Complex reasoning task"
# Extract code blocks from response
llm -x "Write a function to parse JSON safely"
对话
# Continue previous conversation
llm -c "What about error handling?"
# Start new conversation with context
llm -m gpt-4.1 "I'm debugging a memory leak in a Node.js app..."
llm -c "Here's the heap snapshot: <data>"
工作流示例
棘手错误调试
遇到难以解决的错误时:
# Describe the problem with context
llm -m o4-mini -o reasoning_effort=high "I'm debugging this issue:
Error: Connection refused on port 5432
Environment: Docker container, Node.js 22
Stack trace: <paste stack trace>
What I've tried:
1. Verified PostgreSQL is running
2. Checked network settings
3. Tested connection from host
What else should I check?"
架构决策
评估设计选择时:
llm -m claude-opus-4-5 "I need to decide between these approaches:
Option A: Event-driven with Redis pub/sub
Option B: Direct API calls with circuit breaker
Context:
- Microservices architecture
- ~1000 requests/second
- Eventual consistency is acceptable
What are the trade-offs? Which would you recommend?"
代码审查
对代码更改征求第二意见:
git diff HEAD~1 | llm -m gpt-4.1 "Review this code change for:
- Bugs or logic errors
- Security vulnerabilities
- Performance issues
- Missing edge cases
Be specific about line numbers and issues."
计划验证
实现复杂功能之前:
llm -m o3 "Review this implementation plan:
Feature: User authentication with OAuth2
Steps:
1. Add OAuth2 middleware
2. Create /auth/callback endpoint
3. Store tokens in Redis
4. Add refresh token rotation
What am I missing? What could go wrong?"
长文档分析
对于大型代码库或长文档,使用 Gemini 的大上下文窗口:
# Analyze large codebase
find . -name "*.ts" | head -20 | xargs cat | llm -m gemini-2.5-pro "Summarize the architecture and identify any security concerns"
# Analyze long log files
cat large-app.log | llm -m gemini-2.5-pro "Find patterns indicating memory leaks or performance regressions"
多模型对比
对于关键决策,咨询多个模型:
# Ask the same question to different models
QUESTION="Should I use JWT or session cookies for authentication in a Next.js app?"
llm -m gpt-4.1 "$QUESTION"
llm -m claude-sonnet-4-5 "$QUESTION"
llm -m gemini-2.5-pro "$QUESTION"
替代方案
需要新思路时:
llm -m gpt-4.1 "Here's my current approach to <problem>:
<describe approach>
What are alternative ways to solve this? What am I missing?"
最佳实践
提供上下文
- 包含相关代码——通过管道传入文件或粘贴代码片段
- 描述环境——框架、语言版本、依赖项
- 说明已尝试的方法——避免重复建议
- 说明限制条件——性能要求、兼容性需求
编写提示词
# Good: Structured with clear sections
llm -m gpt-4.1 "Problem: <description>
Context:
- Language: TypeScript
- Framework: Express
- Environment: Docker
Error: <error message>
Question: What's causing this and how do I fix it?"
# Bad: Vague without context
llm "Why doesn't this work?"
解读结果
- 验证建议 - 始终在代码库中测试建议
- 考虑多个视角 - 使用不同模型处理同一个问题
- 交叉核对 - 将建议与文档核对
- 结合实际情况调整 - 通用建议可能需要调整
- 模型可能会出错 - 尤其是涉及近期 API 时;请对照官方文档核实
何时不使用
- 简单明了的更改(拼写错误、格式调整)
- 有清晰解决方案且文档完善的操作
- 需要快速处理低风险更改时
- 模式已确立的重复性任务
故障排除
找不到模型
# List available models
llm models
# Install missing plugin
llm install llm-gemini
llm install llm-anthropic
# Update to get latest model names
pip install --upgrade llm llm-gemini llm-anthropic
API 密钥问题
# Re-set API key
llm keys set openai
llm keys set gemini
llm keys set anthropic
# Verify key is set
llm keys
速率限制
如果遇到速率限制:
- 临时切换到其他模型(例如,使用
gpt-4o-mini替代gpt-4.1) - 使用
reasoning_effort=low以减少令牌用量 - 等待一分钟后重试
长回复被截断
对于需要详细回答的复杂问题:
# Use a model with longer output limits
llm -m gemini-2.5-pro "detailed question requiring long answer"
模型名称变动
OpenAI、Google 和 Anthropic 经常更新模型名称。如果模型 ID 无法使用:
llm models list # See all installed models with current IDs
评论
支持 Markdown