tdd

A project rule for test-driven development, a way of writing or checking tests as part of making code changes. It also defines commands for running selected Go tests, starting the service, viewing logs, and checking its status.

In plain words
What is it for?
Use it when testing Go API handlers, starting or stopping the service, monitoring logs, checking the status endpoint, or safely resetting the database.
Why use it?
It gives developers a fixed way to verify changes and inspect failures without producing unnecessary terminal output. It also adds a backup step before resetting the project database.

Cursor rule for 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/burugo/one-mcp/tdd
Clone the repo
git clone --depth 1 https://github.com/burugo/one-mcp

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,929 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 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.00000 $0.01929
Opus 5 $0.00000 $0.00964
Sonnet 5 $0.00000 $0.00386
Haiku 4.5 $0.00000 $0.00193

Measured 2d ago against content hash cc34a1ca0235, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 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.

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

Copies of this mod

1 near-identical copy found in the catalogue:

  • tdd — 88% identical, 20 lines differ
.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 one-mcp 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 one-mcp to stop the service
  • Check service status with ps aux | grep one-mcp | grep -v grep
  • API status endpoint: curl "http://localhost:3003/api/status"

数据库重置和缓存管理

数据库重置规则:

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

完整的数据库重置流程:

# 1. 停止服务
pkill -f one-mcp

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

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

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

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

验证root用户创建:

  • 查看日志:grep "no user exists\|create a root user" backend.log
  • 检查数据库:sqlite3 data/one-mcp.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. 2d ago First seen · 131 lines · 1,929 tokens per session scan A cc34a1ca0235

Subscribe to this mod's changes

tdd is a cursor rule published in the GitHub repository burugo/one-mcp (412 stars, last pushed 15d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,929 tokens. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.