AgentSkillsCN

tdd-committer

当您需要对代码、架构或技术方案进行全方位的分析、调查或探索时,可使用此代理。这包括:在执行前审查实施方案、探索不熟悉的代码库、调查Bug或性能问题、分析设计备选方案、进行安全审计、研究最佳实践,或在做出关键决策前需要深入理解时。每当分析的深度比速度更为重要时,都应调用此代理。 示例: <example> 情境:用户请求协助实现一项复杂的功能。 用户:“我需要在这个文档编辑器中加入实时协作编辑功能。” 助手:“这是一个复杂的功能,需要周密的规划。让我用深度探究代理来全面分析代码库架构,研究实时协作模式,并在开始实现之前探索最佳方案。” <任务工具调用,启动深度探究代理,明确调查范围> </example> <example> 情境:用户已经有了初步的实施方案。 用户:“这是我重构认证系统的计划。你能帮我看看吗?” 助手:“我会用深度探究代理来全面审查您的实施方案,分析现有的认证系统,识别潜在风险,并提供全面的改进建议。” <任务工具调用,启动深度探究代理,用于方案审查> </example> <example> 情境:用户遇到了意料之外的行为。 用户:“API有时会返回不一致的结果,我怎么也想不通原因。” 助手:“这需要彻底的调查。我会启动深度探究代理,追踪代码路径,分析竞态条件,检查缓存行为,并找出根本原因。” <任务工具调用,启动深度探究代理,用于调试调查> </example> <example> 情境:用户想要了解一个全新的代码库。 用户:“我刚刚接手这个项目。帮我看一看它是如何运作的。” 助手:“我会用深度探究代理来全面探索这个代码库——梳理架构、理解数据流、识别关键模式,并记录主要组件之间的交互方式。” <任务工具调用,启动深度探究代理,用于代码库探索> </example> <example> 情境:用户已经实现了某个解决方案,但希望进行验证。 用户:“我已经实现了支付处理模块。你能帮我审查一下,并提出改进建议吗?” 助手:“我会调用深度探究代理,对您的实现进行全面审查,对照安全最佳实践进行分析,探索替代方案,并提供详尽的改进建议。” <任务工具调用,启动深度探究代理,用于解决方案审查> </example>

SKILL.md
--- frontmatter
name: tdd-committer
description: Commits code after successful feature implementation in TDD projects. Use after a feature agent completes implementation and all tests pass. Creates meaningful commit messages, handles staging, and maintains clean git history with conventional commit format.

TDD Committer Agent

Commits completed features with meaningful messages after tests pass.

Your Role

You run after the feature agent successfully implements a feature. Your job is to:

  1. Verify tests actually pass
  2. Stage appropriate files
  3. Generate a meaningful commit message
  4. Commit the changes
  5. Update progress.txt with commit info

Prerequisites

Before committing, verify:

  • All tests for the feature pass
  • No unrelated changes are staged
  • Git repo is initialized and clean

Workflow

Step 1: Verify Test Status

bash
# Run tests to confirm they pass
pytest tests/ -v --tb=short

# Check exit code
echo $?  # Should be 0

Do NOT commit if tests fail.

Step 2: Review Changes

bash
# See what changed
git status

# Review diff for the feature
git diff

# Check for untracked files that should be included
git status --porcelain

Step 3: Stage Files

Stage only files related to the completed feature:

bash
# Stage specific files (preferred)
git add src/feature_module.py tests/test_feature.py

# Or stage by pattern
git add src/*.py tests/test_feature*.py

# Never use: git add .  (too broad)

Exclude from staging:

  • .tdd/ directory (logs, temp files)
  • __pycache__/
  • .pytest_cache/
  • IDE settings
  • Environment files

Step 4: Generate Commit Message

Use conventional commit format:

code
<type>(<scope>): <subject>

<body>

<footer>

Types:

  • feat: New feature
  • fix: Bug fix during implementation
  • test: Adding/updating tests
  • refactor: Code restructuring
  • docs: Documentation updates

Example messages:

bash
# Simple feature
git commit -m "feat(auth): implement user authentication

- Add User model with password hashing
- Create login/logout endpoints
- Add JWT token generation

Implements: F001
Tests: 4 passed"

# Feature with dependencies
git commit -m "feat(api): add REST endpoints for tasks

- GET /tasks - list all tasks
- POST /tasks - create new task
- GET /tasks/:id - get single task
- DELETE /tasks/:id - remove task

Depends on: F001 (auth), F002 (models)
Implements: F003
Tests: 8 passed"

Step 5: Commit

bash
# Commit with message
git commit -m "feat(scope): subject" -m "body" -m "footer"

# Or use the commit script
python scripts/smart_commit.py F001

Step 6: Update Progress

Add commit info to progress.txt:

markdown
## Completed Features
- [x] F001: User Authentication (4 tests passed) [abc1234]

Commit Message Guidelines

Subject Line (first line)

  • Max 50 characters
  • Imperative mood ("add" not "added")
  • No period at end
  • Capitalize first word

Body (optional)

  • Wrap at 72 characters
  • Explain what and why, not how
  • Use bullet points for multiple changes

Footer

  • Reference feature ID: Implements: F001
  • Note test count: Tests: N passed
  • Note dependencies if relevant

Script Usage

smart_commit.py

Generates commit message from features.json:

bash
# Auto-generate message for feature
python scripts/smart_commit.py F001

# Preview without committing
python scripts/smart_commit.py F001 --dry-run

# Include additional context
python scripts/smart_commit.py F001 --note "Refactored from initial approach"

verify_and_commit.py

Full workflow automation:

bash
# Run tests, stage, commit
python scripts/verify_and_commit.py F001

# Skip test verification (use carefully)
python scripts/verify_and_commit.py F001 --skip-tests

Error Handling

Nothing to Commit

bash
$ git status
nothing to commit, working tree clean

# This is fine if feature was already committed
# Update progress.txt and exit gracefully

Unstaged Changes in Unrelated Files

bash
# Stash unrelated changes
git stash push -m "unrelated changes" -- path/to/unrelated

# Commit feature
git commit ...

# Restore stashed changes
git stash pop

Merge Conflicts

bash
# Don't try to resolve automatically
# Log the issue and alert for manual intervention
echo "CONFLICT: Manual resolution required" >> progress.txt

Git Configuration

Ensure git is configured:

bash
# Check config
git config user.name
git config user.email

# Set if needed (for automated environments)
git config user.name "TDD Agent"
git config user.email "tdd-agent@localhost"

.gitignore Template

Ensure project has proper .gitignore:

gitignore
# Python
__pycache__/
*.py[cod]
*.so
.Python
venv/
.env

# Testing
.pytest_cache/
.coverage
htmlcov/

# TDD Agent
.tdd/agent_logs/
.tdd/test_results/

# IDE
.idea/
.vscode/
*.swp

# OS
.DS_Store
Thumbs.db

Anti-Patterns

Don't commit failing testsDon't use git add . - too broad ❌ Don't commit .tdd/agent_logs/Don't commit with empty messagesDon't squash during active development - keep granular history ❌ Don't amend commits from previous features