mcpField
L
llm-advisor

llm-advisor

github.com/ckorhonenAgent 工作流2257 次安装5 周前更新
代码仓库

关于 llm-advisor

llm-advisor 是一项借助 Simon Willison 的 `llm` 命令行工具咨询其他 LLM 的 Agent 技能,面向需要调试、代码审查或设计决策第二意见的开发者。

主要功能

  1. 01通过 `llm` 命令行咨询模型
  2. 02将代码、差异和日志传入提示词
  3. 03带上下文继续对话
  4. 04比较多个模型的回答

适用场景

  1. 01咨询棘手问题的调试思路
  2. 02检查代码变更中的风险
  3. 03比较不同架构方案
  4. 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-minillm -m gpt-4o-mini "question"
通用gpt-4.1llm -m gpt-4.1 "question"
复杂推理o4-minillm -m o4-mini -o reasoning_effort=high "question"
深度推理o3llm -m o3 "question"
高端gpt-4.1llm -m gpt-4.1 "question"

**注意:**运行 llm models,查看已安装的具体模型 ID。OpenAI 模型名称经常变化。截至 2026 年,gpt-4.1 是旗舰 GPT,o3/o4-mini 是推理模型。

Google Gemini 模型
用例模型命令
快速通用gemini-2.0-flashllm -m gemini-2.0-flash "question"
高级推理gemini-2.5-prollm -m gemini-2.5-pro "question"
长上下文(1M+)gemini-2.5-prollm -m gemini-2.5-pro "question"
深度推理gemini-2.5-prollm -m gemini-2.5-pro -o thinking_budget=32000 "question"
Anthropic Claude 模型
用例模型命令
快速/高性价比claude-haiku-4llm -m claude-haiku-4 "question"
通用claude-sonnet-4-5llm -m claude-sonnet-4-5 "question"
最高质量claude-opus-4-5llm -m claude-opus-4-5 "question"
模型选择指南
  1. 快速提问:使用 gpt-4o-mini 或 gemini-2.0-flash
  2. 一般建议:使用 gpt-4.1 或 claude-sonnet-4-5
  3. 复杂调试:使用 o4-mini -o reasoning_effort=high 或 gemini-2.5-pro -o thinking_budget=32000
  4. 代码审查:使用 gpt-4.1 或 claude-sonnet-4-5 进行全面分析
  5. 架构/深度推理:使用 o3 或 claude-opus-4-5
  6. 长上下文(>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?"

最佳实践

提供上下文
  1. 包含相关代码——通过管道传入文件或粘贴代码片段
  2. 描述环境——框架、语言版本、依赖项
  3. 说明已尝试的方法——避免重复建议
  4. 说明限制条件——性能要求、兼容性需求
编写提示词
# 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?"
解读结果
  1. 验证建议 - 始终在代码库中测试建议
  2. 考虑多个视角 - 使用不同模型处理同一个问题
  3. 交叉核对 - 将建议与文档核对
  4. 结合实际情况调整 - 通用建议可能需要调整
  5. 模型可能会出错 - 尤其是涉及近期 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
速率限制

如果遇到速率限制:

  1. 临时切换到其他模型(例如,使用 gpt-4o-mini 替代 gpt-4.1)
  2. 使用 reasoning_effort=low 以减少令牌用量
  3. 等待一分钟后重试
长回复被截断

对于需要详细回答的复杂问题:

# 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