home-mcp: Command for Claude Code

.claude/commands/fix-type-fail.md

fix-type-fail is a command for Claude Code from shenjingnan/home-mcp. It costs 5 tokens per session (1,078 once invoked), scanned A, original, MIT.

A command that systematically analyzes and fixes TypeScript type errors reported by the project's type-check command. TypeScript type errors often mean that code uses the wrong value shape, parameter, property, or module.

In plain words
What is it for?
Use it to fix type definitions, function parameters, imports, type guards, generic types, tests, and third-party type packages, then verify the result with type checks, builds, and tests.
Why use it?
It turns a large error list into categories and a repair order, helping reduce missed issues and unsafe workarounds such as treating values as any type.

Command for Claude Code

Written for Claude Code: argument-hint in frontmatter. Also seen: positional $N argument.

This is shenjingnan/home-mcp's own configuration. It tells Claude Code how to work on home-mcp itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything home-mcp configures →

Reuse

Borrowing it

Nothing to install: this file belongs to shenjingnan/home-mcp. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/shenjingnan/home-mcp/main/.claude/commands/fix-type-fail.md
Clone the repo
git clone --depth 1 https://github.com/shenjingnan/home-mcp

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for fix-type-fail

README.md
[![agentmods](https://agentmods.dev/badge/commands/shenjingnan/home-mcp/fix-type-fail/github.svg)](https://agentmods.dev/commands/shenjingnan/home-mcp/fix-type-fail)
Your own site
<a href="https://agentmods.dev/commands/shenjingnan/home-mcp/fix-type-fail"><img src="https://agentmods.dev/badge/commands/shenjingnan/home-mcp/fix-type-fail/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for fix-type-fail

Your own site · 80×15
<a href="https://agentmods.dev/commands/shenjingnan/home-mcp/fix-type-fail"><img src="https://agentmods.dev/badge/commands/shenjingnan/home-mcp/fix-type-fail.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 5 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,078 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00005 $0.01078
Opus 5 $0.00003 $0.00539
Sonnet 5 $0.00001 $0.00216
Haiku 4.5 $0.00001 $0.00108

Measured 9d ago against content hash e1f6a1555217, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

fix-type-fail scanned grade A with 0 findings 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 9d 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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/fix-type-fail.md · 96 lines

What it actually says

我在目录 <path>$1</path> 执行命令 nr type:check 发现有很多类型错误,如下 $2

请按照以下步骤系统性地分析和修复所有类型错误:

1. 错误分类和初步分析

1.1 解析错误日志

  • 统计错误总数和涉及的文件数量
  • 识别错误类型分布(TS2339、TS2345、TS2352、TS7006等)
  • 按文件分组错误,优先处理错误数量最多的文件

1.2 常见错误类型识别

  • TS2339:属性不存在错误 → 检查接口定义和类型导入
  • TS2345:参数类型不匹配 → 检查函数签名和参数类型
  • TS2352:类型转换错误 → 避免使用 as any,使用类型守卫
  • TS7006:隐式 any 类型 → 添加显式类型注解
  • TS2307:模块找不到 → 检查导入路径和模块导出

2. 制定修复策略

2.1 优先级排序

  1. 高优先级:影响编译的核心类型错误(接口缺失、函数签名错误)
  2. 中优先级:类型注解缺失、可选参数处理
  3. 低优先级:类型推断优化、非空断言优化

2.2 修复方法选择

  • 接口扩展:为缺失的属性添加接口定义
  • 类型守卫:使用 is 函数进行类型保护
  • 泛型优化:使用泛型提高类型安全性
  • 工具类型:合理使用 Partial<T>Required<T> 等工具类型

3. 实施修复

3.1 文件修复顺序

  • 先修复类型定义文件(*.d.tstypes.ts
  • 再修复核心业务逻辑文件
  • 最后修复测试文件

3.2 具体修复步骤

  1. 读取错误文件:逐一分析每个出错的 TypeScript 文件
  2. 理解代码意图:分析代码的业务逻辑和预期行为
  3. 添加类型定义:为缺失的类型创建或扩展接口
  4. 修复类型错误:按照优先级逐个修复错误
  5. 保持向后兼容:确保修复不破坏现有功能

3.3 特殊情况处理

  • 测试文件:使用测试工具函数避免类型断言,参考项目的 test-types.ts
  • 第三方库:检查是否需要安装类型定义包(@types/*
  • 遗留代码:渐进式添加类型,避免大规模重构

4. 验证和测试

4.1 编译验证

  • 运行 nr type:check 确保所有类型错误已修复
  • 运行 nr build 确保代码能够正常编译
  • 检查生成的类型声明文件(*.d.ts

4.2 功能测试

  • 运行相关测试用例:nr test <相关测试文件>
  • 确保修复后的代码功能正常
  • 执行回归测试避免引入新问题

4.3 代码质量检查

  • 执行 pnpm check:fix 进行代码规范检查和自动修复
  • 确保代码符合项目的类型安全要求(如禁用 any 类型)
  • 验证导入导出语句的正确性

5. 文档和预防

5.1 修复记录

  • 记录修复的错误类型和数量
  • 说明采用的主要修复策略
  • 标记需要注意的特殊情况

5.2 预防措施

  • 建议启用更严格的 TypeScript 配置
  • 推荐 ESLint 规则来预防常见类型错误
  • 提供类型安全的最佳实践建议

6. 报告要求

请提供以下详细信息:

  1. 错误统计:按类型和文件分布的错误统计
  2. 修复过程:主要修复策略和关键决策点
  3. 代码变更:重要的类型定义修改和接口扩展
  4. 测试结果:所有验证步骤的执行结果
  5. 质量检查:代码规范检查的发现和修复
  6. 建议改进:避免类似错误再次发生的建议
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. 9d ago First seen · 96 lines · 5 tokens per session scan A e1f6a1555217

Subscribe to this mod's changes

fix-type-fail is a command published in the GitHub repository shenjingnan/home-mcp (21 stars, last pushed 7mo ago), licensed MIT. It adds 5 tokens to every session and 1,078 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.