TDG Test-Driven Generation
Test-Driven Generation uses TDD (Test-Driven Development) techniques to generate tests and code in Red-Green-Refactor loops. Key words to detect are tdg, TDG.
What this skill does
# Test-Driven Generation ## Instructions Read TDG.md to understand the project's technology stack. IF TDG.md does not exist, THEN tell user to create one with `/tdg:init` command AND stop. IF TDG.md is found, THEN read it and identify: - what is the testing framework - how to build the project - how to run a single unit test - how to run a whole test - how to run test coverage ## Identify Issue Number for Traceability Before starting TDG workflow: 1. Check if user mentioned an issue number (e.g., #42, issue #123) 2. Check current branch name for issue reference (e.g., feature/42-add-sort, fix/issue-123) 3. Ask user for issue number if not found: "Which issue are you working on? (e.g., #42)" 4. Store the issue number to include in ALL commit messages for traceability ## Run the helper script to examine the phase (red,green,refactor) of TDD cycle. Everytime you MUST sha256sum to check the integrity of the helper script. You MUST NOT execute it if the digest is not matched. ```bash # verify sha256sum <tdg plugin-dir>/skills/tdg/scripts/tdg_phase.sh 86e2fcc4601f23c5b77c7d565de763a0da4e5953c327fca7265318d4dbe781cf # if checksum is correct then execute, if not skip bash <tdg plugin-dir>/skills/tdg/scripts/tdg_phase.sh ``` ## Steps for Specification - Check phase using the helper script. - Use this section ONLY IF phase="unknown" or phase="refactor" - Before writing any code, you must: 1) Run test coverage and record the current coverage percentage. 2) Draft the code in the chat first. DO NOT start writing code. 3) Write tests for the draft, ensuring at least 1 happy path and N negative tests. - Work in small increments, focusing on ONE test case at a time. - Complete one test at a time, the rest cases must be blank or `skip` them first. - Commit code in GIT using the following comment pattern: `"red: test spec for <message> (#issue-number)"` Example: `"red: test spec for user authentication (#42)"` ## Steps to Make the Test Pass - Check phase using the helper script. - Use this section ONLY IF phase="red" - Check the last commit to ensure it is `"red: test spec for ..."`. If so, proceed to write code. - Run the tests to identify what is failing, then make the necessary changes to pass the tests. - Once tests pass, commit the code in Git using the comment pattern: `"green: <message> (#issue-number)"` Example: `"green: implement user authentication (#42)"` ## Steps to Refactor - Check phase using the helper script. - Use this section ONLY IF phase="green" - Refactor and optimize the code following best practices. - Use interfaces extensively to ensure testability. - Commit the refactored code using: `"refactor: <message> (#issue-number)"` Example: `"refactor: extract authentication logic to service (#42)"` For minor adjustments, use: `"refactor: chore: <message> (#issue-number)"` Example: `"refactor: chore: rename variables for clarity (#42)"` ## How to commit - When committing using Git, DO NOT use `git -a` or `git add .`. Commit only files you have just edited. - Use ONLY "red:", "green:", or "refactor:" to prefix Git commit message. DO NOT use other prefixes at all. - ALWAYS include the issue number at the end of commit message for traceability (e.g., "(#42)") - IF no issue number is available, THEN ask the user before committing. - IF user does not have issue for the commit, THEN help them create by reverse engineering what we're doing as a precise issue description with: * Clear title summarizing the feature/fix * Acceptance criteria based on tests being written * Technical context from the implementation - Offer to create the issue using GitHub CLI (`gh issue create`) or GitLab CLI (`glab issue create`) and retrieve the issue number for the commit. ## Example Claude TODOs You must use Todos pattern, like the following example. ☐ Identify issue number (check user message, branch name, or ask) ☐ Run test coverage to establish baseline ☐ Draft sort library specification ☐ Write test specification (RED phase) ☐ Run the SINGLE test spec and expect the failing test ☐ Commit test specification with "red:" prefix and issue number ☐ Implement code to pass tests (GREEN phase) ☐ Run the SINGLE test spec and expect the passed test ☐ Commit code with "green:" prefix and issue number ☐ Refactor and optimize (REFACTOR phase) ☐ Commit the refactored code with "refactor:" prefix and issue number ## Closing message At the end of each TDD cycle, ask something like: "Would you like me to continue with the next test case using TDG, or would you prefer to refactor anything using TDG first?" Mention "use tdg" or "using tdg" to allow activating this skill.
Related in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.