TDD Guard automates test-driven development enforcement for Claude Code. It benefits developers and operations teams by ensuring code quality and reducing bugs. It integrates with Git hooks and CI/CD pipelines, connecting to Claude Code workflows.
git clone https://github.com/nizos/tdd-guard.githttps://github.com/nizos/tdd-guard
[{"step":"Identify the feature or module you're working on and replace [FEATURE_NAME] in the prompt with its name.","tip":"Start with small, isolated features to practice TDD effectively. Use the prompt to generate your first failing test before writing any implementation code."},{"step":"Replace [PROJECT_NAME], [TEST_FRAMEWORK], and [LANGUAGE] in the prompt with your project's details. For example, use 'pytest' for [TEST_FRAMEWORK] and 'Python' for [LANGUAGE].","tip":"Ensure your test framework and language are correctly specified to generate accurate test code and implementation stubs."},{"step":"Run the generated test to confirm it fails, then implement the minimal code to make it pass. Use the output as a guide for your TDD cycle.","tip":"Avoid writing more code than necessary to pass the test. Refactor only after the test passes to maintain clean code principles."},{"step":"Integrate the provided Git pre-commit hook or CI/CD configuration into your project to automate TDD enforcement.","tip":"Test the pre-commit hook locally before pushing to ensure it works as expected. Use `chmod +x .git/hooks/pre-commit` to make it executable."},{"step":"Iterate through the TDD cycle (Red-Green-Refactor) for each small feature or bug fix, using the prompt to guide your next steps.","tip":"Use the prompt repeatedly to generate new test cases and implementations as you expand your feature. Keep tests focused and isolated."}]
Enforce test-first development by blocking code implementation until tests are written.
Prevent over-implementation by restricting code changes to only what is necessary for passing tests.
Integrate linting rules to ensure code quality during refactoring processes.
Customize validation rules to align with specific TDD practices and team standards.
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/nizos/tdd-guardCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Enforce Test-Driven Development (TDD) for [PROJECT_NAME] using TDD Guard. For the feature [FEATURE_NAME], generate the minimal test case that would fail first, then provide the minimal implementation to make it pass. Ensure the test follows the Arrange-Act-Assert pattern and the implementation is just enough to satisfy the test. Use [TEST_FRAMEWORK] for testing and [LANGUAGE] for implementation. Include a Git pre-commit hook command to run the test suite after implementation.
### TDD Guard Report for Feature: User Authentication
**Step 1: Minimal Failing Test**
```python
# tests/test_auth.py
def test_user_can_authenticate_with_valid_credentials():
from app.auth import authenticate
# Arrange
username = "testuser"
password = "securepassword123"
# Act & Assert
result = authenticate(username, password)
assert result is False, "Should return False for invalid credentials"
```
**Step 2: Minimal Implementation**
```python
# app/auth.py
def authenticate(username: str, password: str) -> bool:
return False # Hardcoded to fail the test initially
```
**Step 3: Next Test Case**
```python
def test_user_authentication_fails_with_invalid_password():
from app.auth import authenticate
# Arrange
username = "testuser"
password = "wrongpassword"
# Act & Assert
result = authenticate(username, password)
assert result is False, "Should return False for invalid password"
```
**Step 4: Updated Implementation**
```python
# app/auth.py
def authenticate(username: str, password: str) -> bool:
# Hardcoded valid credentials for demonstration
return username == "testuser" and password == "securepassword123"
```
**Git Pre-Commit Hook Command:**
```bash
#!/bin/sh
pytest tests/ --maxfail=1 --disable-warnings
```
**CI/CD Integration (GitHub Actions Example):**
```yaml
name: TDD Guard CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: pip install pytest
- name: Run tests
run: pytest tests/ --maxfail=1 --disable-warnings
```Your one-stop shop for church and ministry supplies.
AI assistant built for thoughtful, nuanced conversation
Automate your browser workflows effortlessly
IronCalc is a spreadsheet engine and ecosystem
Enterprise workflow automation and service management platform
Automate your spreadsheet tasks with AI power
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan