tdd-workflow
यह क्या करती है
यह स्किल आपको व्यवस्थित और भरोसेमंद तरीके से कोड लिखने में मदद करता है। यह आपको एक चक्र में गाइड करता है: पहले एक फेल होने वाला टेस्ट लिखना, फिर उसे पास कराने वाला सबसे सरल कोड लिखना, और आखिर में कोड की क्वालिटी सुधारना।
कब इस्तेमाल करें
- ✓जब कोई नया फीचर शुरू करना हो।
- ✓जब कोई बग ठीक करना हो।
- ✓जब जटिल लॉजिक पर काम करना हो।
Skill का लिंक
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/tdd-workflow/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मुझे TDD चक्र का इस्तेमाल करके दो नंबर जोड़ने वाला फंक्शन बनाने में मदद करो।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
AI एक चक्र का पालन करता है: पहले आप बताते हैं कि कोड को क्या करना चाहिए, और AI एक फेल होने वाला टेस्ट लिखता है। फिर AI उस टेस्ट को पास कराने वाला सबसे सरल कोड लिखता है। आखिर में AI कोड की समीक्षा करता है और टेस्ट न तोड़ते हुए उसे बेहतर बनाता है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
TDD Workflow
Write tests first, code second.
1. The TDD Cycle
🔴 RED → Write failing test
↓
🟢 GREEN → Write minimal code to pass
↓
🔵 REFACTOR → Improve code quality
↓
Repeat...
2. The Three Laws of TDD
- Write production code only to make a failing test pass
- Write only enough test to demonstrate failure
- Write only enough code to make the test pass
3. RED Phase Principles
What to Write
| Focus | Example |
|---|---|
| Behavior | "should add two numbers" |
| Edge cases | "should handle empty input" |
| Error states | "should throw for invalid data" |
RED Phase Rules
- Test must fail first
- Test name describes expected behavior
- One assertion per test (ideally)
4. GREEN Phase Principles
Minimum Code
| Principle | Meaning |
|---|---|
| YAGNI | You Aren't Gonna Need It |
| Simplest thing | Write the minimum to pass |
| No optimization | Just make it work |
GREEN Phase Rules
- Don't write unneeded code
- Don't optimize yet
- Pass the test, nothing more
5. REFACTOR Phase Principles
What to Improve
| Area | Action |
|---|---|
| Duplication | Extract common code |
| Naming | Make intent clear |
| Structure | Improve organization |
| Complexity | Simplify logic |
REFACTOR Rules
- All tests must stay green
- Small incremental changes
- Commit after each refactor
6. AAA Pattern
Every test follows:
| Step | Purpose |
|---|---|
| Arrange | Set up test data |
| Act | Execute code under test |
| Assert | Verify expected outcome |
7. When to Use TDD
| Scenario | TDD Value |
|---|---|
| New feature | High |
| Bug fix | High (write test first) |
| Complex logic | High |
| Exploratory | Low (spike, then TDD) |
| UI layout | Low |
8. Test Prioritization
| Priority | Test Type |
|---|---|
| 1 | Happy path |
| 2 | Error cases |
| 3 | Edge cases |
| 4 | Performance |
9. Anti-Patterns
| ❌ Don't | ✅ Do |
|---|---|
| Skip the RED phase | Watch test fail first |
| Write tests after | Write tests before |
| Over-engineer initial | Keep it simple |
| Multiple asserts | One behavior per test |
| Test implementation | Test behavior |
10. AI-Augmented TDD
Multi-Agent Pattern
| Agent | Role |
|---|---|
| Agent A | Write failing tests (RED) |
| Agent B | Implement to pass (GREEN) |
| Agent C | Optimize (REFACTOR) |
Remember: The test is the specification. If you can't write a test, you don't understand the requirement.
When to Use
This skill is applicable to execute the workflow or actions described in the overview.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
अक्सर पूछे जाने वाले सवाल
'RED', 'GREEN', 'REFACTOR' का क्या मतलब है?
'RED' तब होता है जब टेस्ट फेल होता है। 'GREEN' तब होता है जब कोड टेस्ट को पास करता है। 'REFACTOR' का मतलब है सब कुछ चालू रखते हुए कोड को बेहतर बनाना।
टेस्ट कोड से पहले क्यों लिखें?
पहले टेस्ट लिखने से आप साफ जानते हैं कि कोड को क्या करना है, और बेवजह का कोड लिखने से बच जाते हैं।
'YAGNI' क्या है?
YAGNI का मतलब है 'You Aren't Gonna Need It'। यह एक सिद्धांत है जिसमें आप सिर्फ वही कोड लिखते हैं जो अभी सख्ती से ज़रूरी हो।
जानकारी
लेखक का मूल विवरण
Test-Driven Development workflow principles. RED-GREEN-REFACTOR cycle.
लोकप्रियता
- GitHub स्टार
- 48k
- रैंकिंग में स्थान
- #5933
- लाइसेंस
- MIT
- अपडेट की गई
- 15/10/2026
कमेंट
- …
इस repository की और skills
00-andruia-consultant
48kआपके एजेंट को AI प्रोजेक्ट शुरू करने या उन्हें बेहतर बनाने में मदद करता है। यह code का विश्लेषण करता है, tools सुझाता है और स्पेनिश भाषा में action plan बनाता है।
007
48kआपका एजेंट security audit और threat modeling करता है। यह प्रोजेक्ट को हमलों और कमजोरियों से बचाने में काम आता है।
10-andruia-skill-smith
48kआपके एजेंट को AI tools बनाने या उन्हें बेहतर करने में मदद करता है। यह तय करता है कि tools कैसे काम करेंगे, documentation लिखता है और structure की जांच करता है।
20-andruia-niche-intelligence
48kआपका एजेंट किसी खास industry का summary बनाता है। भरोसेमंद स्रोतों की मदद से यह प्रोजेक्ट का संदर्भ, नियम, इस्तेमाल के तरीके और जोखिम समझने में मदद करता है।
मिलती-जुलती skills
test-driven-development
311kयह आपके एजेंट को किसी भी फ़ीचर या सुधार से पहले पहले असफल होने वाला टेस्ट लिखना, उसे असफल होते देखना, फिर पास करने वाला सबसे छोटा कोड लिखना सिखाती है।
verification-before-completion
311kयह आपके एजेंट को किसी काम, सुधार या build के पूरा या पास होने का दावा करने से पहले असली जांच चलाकर उसका आउटपुट पढ़ना सिखाती है।
migrate-to-shoehorn
310kआपकी टेस्ट फ़ाइलों में जोखिम भरे type casts की जगह shoehorn लाइब्रेरी लगाती है, ताकि टेस्ट अधूरे डेटा से भी type checks पास कर सकें।