AgentSkillsCN

mcpx-code-quality

适用于在 MCPX 项目中提交代码变更时使用。每次提交或发起 PR 前均需完成此项操作。

SKILL.md
--- frontmatter
name: mcpx-code-quality
description: Use when submitting code changes in the MCPX project. REQUIRED before any commit or PR.

MCPX Code Quality

Overview

提交前必须通过所有检查:lint → types → test

The Check Sequence

bash
# 1. 格式化代码
uv run ruff format src/mcpx tests/
uv run ruff check --fix src/mcpx tests/

# 2. 类型检查
uv run mypy src/mcpx

# 3. 运行测试
uv run pytest tests/ -v --cov=src/mcpx

Exit Codes Matter

bash
# 如果任何命令失败,停止!
uv run ruff check src/mcpx tests/ || exit 1
uv run mypy src/mcpx || exit 1
uv run pytest tests/ -v || exit 1

Quality Standards

工具用途配置标准
ruff代码检查和格式化line-length=1000 errors
mypy类型检查strict 模式0 errors
pytest测试pytest-asyncio覆盖率 ≥ 70%

Common Mistakes

MistakeFix
跳过类型检查mypy 发现的类型错误会在运行时爆炸
忽略 ruff 警告警告通常是潜在 bug
覆盖率 < 70%添加更多测试用例

Pre-Commit Checklist

code
□ ruff format 完成
□ ruff check 0 错误
□ mypy 0 错误
□ pytest 全部通过
□ 覆盖率 ≥ 70%

Iron Law

code
任何检查失败?不要提交。修复后再检查。

NO EXCEPTIONS:
- "这只是个小改动" → 小改动也引入 bug
- "我稍后修复" → 稍后 = 永远不
- "CI 会检查的" → 本地先检查,不要浪费 CI 时间