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.
curl -O https://raw.githubusercontent.com/shenjingnan/home-mcp/main/.claude/commands/test-create.mdgit clone --depth 1 https://github.com/shenjingnan/home-mcpWrote 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.
[](https://agentmods.dev/commands/shenjingnan/home-mcp/test-create)<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>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.
| Model | Per session | Once 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 |
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.
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、空字符串、空数组
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.
- 8d ago First seen · 306 lines · 0 tokens per session scan A 27236477eadb
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.
Other commands, from other repositories
test-tdd
Run when user calls /test-tdd. Scans modified files, locates their corresponding unit/integration test suites, and runs them.
kill-mutants
Analyze surviving mutants from a mutation testing run and write targeted unit tests to kill them. Re-runs mutations to confirm kills.
lg:node
Create, modify, and manage nodes in LangGraph graphs including LLM nodes, tool nodes, human-in-the-loop, subgraphs, and conditional nodes.
pr-enhance
Command "pr-enhance" from ruvnet/ruflo, covering pr-enhance, usage, options, examples and enhance pr.
test
Execute a comprehensive test run for the following target.
frappe-test
Run unit and integration tests for Frappe apps with coverage reports.