home-mcp: Command for Claude Code

.claude/commands/test-create.md

test-create is a command for Claude Code from shenjingnan/home-mcp. It costs 5 tokens per session (2,086 once invoked), scanned A, original, MIT.

A command that creates tests for a specified project file or module. It examines the target's behavior, normal cases, boundary conditions, errors, external dependencies, and the project's existing test style.

In plain words
What is it for?
Use it to create tests for MCP tools, service classes, utility functions, and type-related code, including validation, API calls, data processing, errors, and edge cases.
Why use it?
It helps turn an untested piece of code into a structured test file and makes the required mocks and scenarios explicit.

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/test-create.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 test-create

README.md
[![agentmods](https://agentmods.dev/badge/commands/shenjingnan/home-mcp/test-create.svg)](https://agentmods.dev/commands/shenjingnan/home-mcp/test-create)
Your own site
<a href="https://agentmods.dev/commands/shenjingnan/home-mcp/test-create"><img src="https://agentmods.dev/badge/commands/shenjingnan/home-mcp/test-create.svg" alt="Measured on agentmods" 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 2,086 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.02086
Opus 5 $0.00003 $0.01043
Sonnet 5 $0.00001 $0.00417
Haiku 4.5 $0.00001 $0.00209

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

Security

Grade A, and why

test-create 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 8d 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/test-create.md · 306 lines

How it starts

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

$1 $2

我需要为项目中的代码创建测试用例。请帮我生成完整的测试文件:

1. 分析测试需求

基于我提供的测试类型 <test-type> 和目标文件/模块 <target-file-or-module>

  • 确定测试范围:分析目标代码的功能和接口
  • 识别测试场景:正常流程、边界条件、错误处理
  • 设计Mock策略:需要模拟的外部依赖和数据

2. 支持的测试类型

mcp-tool - MCP工具测试

  • 目标:MCP工具服务类的完整测试
  • 测试重点
    • 参数验证(Zod schema)
    • Home Assistant API调用
    • 设备查找和过滤逻辑
    • 错误处理和用户友好的错误消息
  • Mock对象:HassService、设备状态数据

service - 服务类测试

  • 目标:业务逻辑服务类的单元测试
  • 测试重点
    • 业务逻辑正确性
    • 数据转换和处理
    • 异常处理流程
    • 性能和边界条件
  • Mock对象:外部API、数据库连接

utility - 工具函数测试

  • 目标:纯函数和工具方法的测试
  • 测试重点
    • 输入输出正确性
    • 边界值处理
    • 类型安全性
    • 算法效率
  • Mock对象:通常无需Mock,纯函数测试

type - 类型定义测试

  • 目标:TypeScript类型和接口的测试
  • 测试重点
    • 类型构造函数
    • 类型守卫函数
    • 错误类型定义
    • 常量和配置对象
  • Mock对象:根据具体需求定

3. 测试文件结构模板

基于项目测试配置和现有测试模式:

3.1 基础结构

import { describe, expect, it, beforeEach, afterEach, vi } from "vitest";
// 导入要测试的模块
import { {TargetClass}, {TargetFunction} } from "../{target-module}";
// 导入类型定义
import type { {TargetType} } from "../{target-module}";

describe("{测试描述}", () => {
  // 测试设置和清理
  beforeEach(() => {
    // 测试前的准备工作
  });

  afterEach(() => {
    // 测试后的清理工作
    vi.clearAllMocks();
  });

  // 测试用例分组
  describe("{功能分组}", () => {
    it("应该正确处理基本场景", async () => {
      // 基础功能测试
    });

    it("应该正确处理边界条件", async () => {
      // 边界条件测试
    });

    it("应该正确处理错误情况", async () => {
      // 错误处理测试
    });
  });
});

3.2 Mock设置模式

// Mock外部依赖
vi.mock("../{dependency-module}", () => ({
  {DependencyClass}: vi.fn(),
  {dependencyFunction}: vi.fn(),
}));

// Mock数据生成
const createMock{TargetType} = (overrides: Partial<{TargetType}> = {}): {TargetType} => ({
  // 默认Mock数据
  ...overrides,
});

4. 测试覆盖要求

基于项目覆盖率阈值(80%函数、行、语句,70%分支):

4.1 必须覆盖的场景

  • 正常流程:所有主要功能路径
  • 边界条件:最小值、最大值、空值、null/undefined
  • 错误处理:所有异常分支和错误码
  • 异步操作:Promise、async/await的各种状态

4.2 测试数据设计

  • 有效数据:符合预期的正常输入
  • 无效数据:各种格式错误的输入
  • 边界数据:临界值和极值
  • 特殊数据:null、undefined、空字符串、空数组

Read the full file on GitHub · 306 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. 8d ago First seen · 306 lines · 0 tokens per session scan A 27236477eadb

Subscribe to this mod's changes

test-create 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 2,086 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.