tdd

tdd is a cursor rule for Cursor from WeatherPal-AI/MCP-handle. It costs 0 tokens per session (1,946 once invoked), scanned A, a copy of tdd, Apache-2.0.

Project rules for test-driven development, or TDD, a practice of using automated tests to guide code changes. They specify how to verify a Go API service, start it, inspect logs, check its status, and handle its database safely.

In plain words
What is it for?
Use them when changing the Go API handlers, running focused tests, starting or stopping the service, monitoring errors, or resetting its database.
Why use it?
They make testing and service operation consistent while avoiding excessive test output and requiring a backup before database deletion.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/. Also seen: mentions Cursor.

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 rules/weatherpal-ai/mcp-handle/tdd
Clone the repo
git clone --depth 1 https://github.com/WeatherPal-AI/MCP-handle

Made for: Cursor.

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 tdd

README.md
[![agentmods](https://agentmods.dev/badge/rules/weatherpal-ai/mcp-handle/tdd.svg)](https://agentmods.dev/rules/weatherpal-ai/mcp-handle/tdd)
Your own site
<a href="https://agentmods.dev/rules/weatherpal-ai/mcp-handle/tdd"><img src="https://agentmods.dev/badge/rules/weatherpal-ai/mcp-handle/tdd.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,946 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin 88% copy Near-identical to another mod 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.00000 $0.01946
Opus 5 $0.00000 $0.00973
Sonnet 5 $0.00000 $0.00389
Haiku 4.5 $0.00000 $0.00195

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

Security

Grade A, and why

tdd scanned grade A 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 6d 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

- API status endpoint: `curl "http://localhost:3003/api/status"`
Origin

This is a copy

88% identical to tdd — 20 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

mcp_handle_status/.cursor/rules/tdd.mdc · 131 lines

How it starts

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

Test-Driven Development (TDD)

Final Verification: Always use: go test -v ./backend/api/handler/... | grep FAIL

Debugging & Handling Verbose Output: Avoid go test -v ./... directly in the terminal due to excessive output. Recommended Alternatives:

  • Specific Tests: go test -v ./... -run ^TestSpecificFunction$ (Fastest for pinpointing).

Project Startup and Logging Rules

Service Startup:

  • Use bash ./run.sh to start the mcp-handle-status service
  • This script automatically loads .env, ensures PATH, kills port 3000 processes, and starts the Go backend in background
  • Logs are output to backend.log

Log Monitoring:

  • Use tail -f backend.log to monitor real-time logs
  • Use tail -n 50 backend.log to view recent log entries
  • Use grep "ERROR\|WARN\|Failed" backend.log to filter error messages Service Management:
  • Use pkill -f mcp-handle-status to stop the service
  • Check service status with ps aux | grep mcp-handle-status | grep -v grep
  • API status endpoint: curl "http://localhost:3003/api/status"

数据库重置和缓存管理

数据库重置规则:

  • 重要: 删除数据库前必须先备份:cp data/mcp-handle-status.db data/mcp-handle-status.db.backup.$(date +%Y%m%d_%H%M%S)
  • 仅删除数据库文件 rm -f data/mcp-handle-status.db 是不够的
  • 必须同时清理Redis缓存: redis-cli flushdbredis-cli flushall
  • 原因:用户列表查询有缓存机制,如果缓存中存在用户数据,系统不会创建新的root用户

完整的数据库重置流程:

# 1. 停止服务
pkill -f mcp-handle-status

# 2. 备份现有数据库
cp data/mcp-handle-status.db data/mcp-handle-status.db.backup.$(date +%Y%m%d_%H%M%S)

# 3. 删除数据库文件
rm -f data/mcp-handle-status.db

# 4. 清理Redis缓存
redis-cli flushdb

# 5. 重新启动服务
bash ./run.sh

验证root用户创建:

  • 查看日志:grep "no user exists\|create a root user" backend.log
  • 检查数据库:sqlite3 data/mcp-handle-status.db "SELECT id, username, LENGTH(token) as token_length FROM users;"

前端API调用规范

API路径构建:

  • 当使用 frontend/src/utils/api.ts 中导出的 api 实例进行API调用时 (例如 api.get, api.post 等),请勿在请求路径中再次添加 /api 前缀
  • 这是因为 api 实例的 baseURL 已经被配置为 /api,重复添加会导致 /api/api/ 这样的错误路径。
  • 正确示例: api.get('/user/self')api.post('/user', data)
  • 错误示例: api.get('/api/user/self')

Read the full file on GitHub · 131 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. 6d ago First seen · 131 lines · 1,946 tokens per session scan A de8ddcdce31f

Subscribe to this mod's changes

tdd is a cursor rule published in the GitHub repository WeatherPal-AI/MCP-handle (254 stars, last pushed 10mo ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 1,946 tokens. A static security scan graded it A with 1 finding (makes network calls). It is 88% identical to tdd, differing in 20 lines, and is treated as a copy.