askill
developer

developerSafety 85Repository

Implement code using TDD (Test-Driven Development). Write tests first, then code. Use for features, bug fixes, and refactoring with Red-Green-Refactor cycle.

0 stars
1.2k downloads
Updated 2/14/2026

Package Files

Loading files...
SKILL.md

Developer Skill

Core Philosophy

"Test First, Code Second." (TDD - Test-Driven Development)

Write tests that define expected behavior BEFORE writing implementation code. This ensures code is testable, requirements are clear, and regressions are prevented.


TDD Principles (MANDATORY)

All code changes follow Test-Driven Development:

Task TypeTDD Approach
Bug FixWrite a failing test that reproduces the bug FIRST, then fix
FeatureWrite tests that define expected behavior FIRST, then implement
RefactorEnsure tests exist and pass, refactor, verify tests still pass

The Red-Green-Refactor Cycle

┌─────────────────────────────────────────────────────────────────┐
│  1. RED        →    2. GREEN      →    3. REFACTOR              │
│  Write failing      Write minimum       Clean up code           │
│  test               code to pass        (tests stay green)      │
└─────────────────────────────────────────────────────────────────┘

Detailed cycle protocols: See TDD_CYCLE.md for complete Red-Green-Refactor workflows by task type.


Quick Start

1. Write a Failing Test (RED)

test("calculates discount correctly", () => {
  const result = calculateDiscount(100);
  expect(result).toBe(10); // 10% discount
});

Run test → FAILS (function doesn't exist)

2. Write Minimum Code (GREEN)

function calculateDiscount(amount) {
  return amount * 0.1;
}

Run test → PASSES

3. Refactor (Keep Tests Green)

const DISCOUNT_RATE = 0.1;

function calculateDiscount(amount) {
  return amount * DISCOUNT_RATE;
}

Run test → PASSES


Tool Usage (CRITICAL)

⛔ NEVER create temporary bash scripts for file modifications

  • ALWAYS use Edit tool for modifying existing files
  • ALWAYS use Write tool for creating new files
  • ALWAYS use Read tool before editing
  • NEVER create temporary scripts (fix.sh, replace.sh, etc.)
  • NEVER use sed/awk/perl for source code modifications

See TOOLS.md for:

  • Complete tool usage guidelines
  • File modification rules
  • Examples for RED/GREEN/REFACTOR phases
  • Anti-patterns to avoid

Reference Documents

For detailed information, see:

  • TDD_CYCLE.md - Detailed Red-Green-Refactor cycle, feature implementation, bug fixes, refactoring protocols
  • TOOLS.md - Tool usage for file modifications (Edit/Write/Read)
  • EXAMPLES.md - Language-specific test commands and patterns

Protocol by Task Type

Feature Implementation

  1. Write failing test (RED)
  2. Run test → verify it fails
  3. Write minimum code (GREEN)
  4. Run test → verify it passes
  5. Refactor → verify tests still pass
  6. Repeat for next behavior

See TDD_CYCLE.md for detailed protocol.

Bug Fix

  1. Write failing test that reproduces bug (RED)
  2. Run test → verify it fails (confirms bug exists)
  3. Fix the code (GREEN)
  4. Run test → verify it passes (confirms fix)
  5. Run all tests → verify no regressions

See TDD_CYCLE.md for detailed protocol.

Refactoring

  1. Ensure tests exist and pass (baseline)
  2. Make ONE refactoring change
  3. Run tests → verify still pass
  4. Repeat steps 2-3
  5. Final test run → confirm no regressions

See TDD_CYCLE.md for detailed protocol.


Language-Specific Commands

StackTest CommandWatch Mode
JavaScript/TypeScriptnpm testnpm test -- --watch
Pythonpytestpytest --watch or ptw
Gogo test ./...gotestsum --watch
Rubybundle exec rspecguard
Rustcargo testcargo watch -x test
Javamvn testIDE integration

See EXAMPLES.md for complete language-specific patterns.


Code Quality Gates

Before considering implementation complete:

  • TDD followed: Tests written before code
  • All tests pass: No failures
  • Code follows project conventions: Linting, formatting, naming
  • No security vulnerabilities: No SQL injection, XSS, auth issues, etc.
  • Changes are minimal and focused: Only what's needed
  • No over-engineering: YAGNI (You Aren't Gonna Need It)
  • Comments only on non-obvious logic: Code should be self-documenting

Anti-Patterns to Avoid

Anti-PatternProblemInstead
Write code first, tests laterTests become afterthought, coverage gapsAlways write test first
Test implementation detailsBrittle tests that break on refactorTest behavior/outcomes
Large test-code cyclesLose focus, harder to debugSmall incremental cycles
Skip the red phaseDon't know if test actually worksAlways see test fail first
Over-engineer in green phaseWasted effort, complexityMinimum code to pass
Skip refactor phaseTechnical debt accumulatesClean up while context fresh

Test Writing Guidelines

Good Tests Are:

  • Fast - Run quickly, encourage frequent execution
  • Isolated - Don't depend on other tests or external state
  • Repeatable - Same result every time
  • Self-validating - Pass or fail, no manual inspection
  • Timely - Written before the code (TDD)

Test Structure (Arrange-Act-Assert):

test("description of expected behavior", () => {
  // Arrange: Set up test data and conditions
  const input = createTestData();

  // Act: Execute the code under test
  const result = functionUnderTest(input);

  // Assert: Verify the expected outcome
  expect(result).toEqual(expectedValue);
});

See TDD_CYCLE.md for complete guidelines.


Checklist

Before marking implementation complete:

  • TDD followed: Tests written before code
  • Red phase verified: Saw tests fail first
  • Green phase minimal: No over-engineering
  • Refactor phase done: Code is clean
  • All tests pass: No failures
  • No regressions: Existing tests still pass
  • Quality gates met: Conventions, security, minimal changes

Cross-Skill Integration

SituationSkill to invokeHow
Need to design before implementingarchitect skillRead skills/architect/SKILL.md
Tests reveal security concernsecurity-reviewer skillRead skills/security-reviewer/SKILL.md
Implementation needs code reviewcode-reviewer skillRead skills/code-reviewer/SKILL.md
Bug discovered during TDDdebugging skillRead skills/debugging/SKILL.md
Need to refactor after Green phaserefactoring skillRead skills/refactoring/SKILL.md
UI implementation needs e2e teststesting skill + Playwright MCPRead skills/testing/SKILL.md

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

88/100Analyzed 2/19/2026

Comprehensive TDD skill with clear Red-Green-Refactor cycle, detailed protocols for features/bug fixes/refactoring, language-specific commands, tool usage guidelines, and cross-skill integration. Well-structured with actionable steps, good use of triggers/tags, and reference documents. Slight deduction for missing https icon and some reference docs being external links rather than included.

85
90
90
85
90

Metadata

Licenseunknown
Version-
Updated2/14/2026
Publishermicaelmalta

Tags

databasesecuritytesting