fix

A command for fixing build, type-checking, and compilation errors with only the smallest necessary code changes. It covers common issues such as missing types, invalid imports, null values, configuration errors, and missing dependencies.

In plain words
What is it for?
Use it to collect build and TypeScript errors, fix them one at a time, and verify that the full build passes.
Why use it?
It helps get a project building again without also refactoring code, changing its design, or adding features.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/xiaobei930/cc-best/fix
Clone the repo
git clone --depth 1 https://github.com/xiaobei930/cc-best
Per session 27 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,706 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00027 $0.01706
Opus 5 $0.00014 $0.00853
Sonnet 5 $0.00005 $0.00341
Haiku 4.5 $0.00003 $0.00171

Measured 2d ago against content hash 6dc8d8b4220f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade C, and why

fix scanned grade C with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

rm -rf .next node_modules/.cache && npm run build
commands/fix.md · 276 lines

How it starts

The opening of the file, as written. The whole thing — 276 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/fix - 构建错误修复

专注于快速修复构建/类型/编译错误。核心原则:最小化 diff,只修错误,不重构。

角色定位

  • 身份: 构建错误修复专家
  • 目标: 让构建通过,以最小改动修复错误
  • 原则: 精准、快速、不引入新问题

核心理念

只修复错误,不改其他任何东西

做什么

✅ 添加缺失的类型注解 ✅ 修复导入/导出错误 ✅ 添加空值检查 ✅ 修复配置文件错误 ✅ 安装缺失的依赖

不做什么

❌ 重构代码 ❌ 改变架构 ❌ 重命名变量 ❌ 添加新功能 ❌ 优化性能 ❌ 改善代码风格

工作流程

1. 收集所有错误
   ├─ 运行 npx tsc --noEmit(TypeScript)
   ├─ 运行 npm run build(构建)
   └─ 记录所有错误数量

2. 分类错误
   ├─ 类型推断错误
   ├─ 空值/未定义错误
   ├─ 导入/导出错误
   ├─ 配置错误
   └─ 依赖缺失

3. 逐个修复(最小化改动)
   ├─ 每次只改一处
   ├─ 改完立即验证
   └─ 记录修复进度

4. 验证构建通过
   └─ 运行完整构建命令

常见错误模式与修复

1. 类型推断失败

// ❌ 错误: Parameter 'x' implicitly has 'any' type
function process(data) {
  return data.value;
}

// ✅ 修复: 添加类型注解(最小改动)
function process(data: any) {
  // 或更具体的类型
  return data.value;
}

2. 空值/未定义错误

// ❌ 错误: Object is possibly 'undefined'
const name = user.profile.name;

// ✅ 修复: 添加可选链
const name = user?.profile?.name;

3. 缺少属性

// ❌ 错误: Property 'age' does not exist on type 'User'
interface User {
  name: string;
}
const user: User = { name: "Tom", age: 20 };

// ✅ 修复: 添加缺失属性
interface User {
  name: string;
  age?: number; // 可选属性
}

4. 导入错误

// ❌ 错误: Cannot find module '@/lib/utils'

// ✅ 修复方案 1: 检查 tsconfig paths
// ✅ 修复方案 2: 使用相对路径
import { util } from "../lib/utils";

// ✅ 修复方案 3: 安装缺失的包
// npm install @/lib/utils

5. 异步函数错误

// ❌ 错误: 'await' is only valid in async function
function getData() {
  const data = await fetch("/api");
}

// ✅ 修复: 添加 async
async function getData() {
  const data = await fetch("/api");
}

6. React Hooks 错误

// ❌ 错误: Hooks can only be called inside function component
if (condition) {
  const [state, setState] = useState(0);
}

// ✅ 修复: 移到顶层
const [state, setState] = useState(0);
if (condition) {
  // 使用 state
}

诊断命令

# TypeScript 类型检查
npx tsc --noEmit

# 显示所有错误(不中断)
npx tsc --noEmit --pretty

# 检查特定文件
npx tsc --noEmit src/path/to/file.ts

# Next.js 构建
npm run build

# ESLint 检查
npx eslint . --ext .ts,.tsx

# 清理缓存重试
rm -rf .next node_modules/.cache && npm run build

Read the full file on GitHub · 276 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 276 lines · 27 tokens per session scan C 6dc8d8b4220f

Subscribe to this mod's changes

fix is a command published in the GitHub repository xiaobei930/cc-best (50 stars, last pushed 2mo ago), licensed MIT. It adds 27 tokens to every session and 1,706 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.