اسکیلیکس | Skilliks مهارت‌های تاییدشده برای هوش مصنوعی

Test-Driven Development

آزاد تازه‌وارد تاییدشده امن

برای کارهای کیفیت کد و تست، «Test-Driven Development» یک راهنمای کوتاه و روشن است: مسیر «نوشتن و اجرای تست خودکار» را مشخص می‌کند و آزمون‌وخطا را کم می‌کند. داخلش ۶ گام مشخص هست و با Claude Code، OpenAI Codex، Cursor کار می‌کند.

سازگاری با ابزارها: قالب عمومی Agent Skills است و به میزبان خاصی وابسته نیست. مشاهدهٔ جدول سازگاری

متن دستورالعمل (SKILL.md)

دسترسی کامل فعال است
---
name: "astack-tdd"
description: "Build features or fixes with failing tests at agreed seams. Use for test-first work, \"red-green-refactor\", or integration tests. Keep refactoring in review rather than the implementation loop."
license: "MIT"
metadata:
  astack-version: "0.3.0"
  source: "astack"
---

# Test-Driven Development

Use the red then green loop to build tests worth keeping.
Apply every section before and during each cycle.
These rules define useful tests, their seams, bad patterns and the loop itself.

Before code exploration, read the domain glossary when present.
Use `CONTEXT.md`, or `GLOSSARY.md` where the repo already uses that name.
Match its vocabulary in test names and interfaces.
Respect ADRs in the affected area.

## What a good test is

Test behavior through public interfaces.
Keep tests independent from internal structure so they survive a full implementation rewrite.
A name such as "user can checkout with valid cart" states a capability as a specification.
Use [tests.md](tests.md) for examples and [mocking.md](mocking.md) for mocking guidance.

## Seams: where tests go

A seam is the interface where a test observes behavior without accessing internals.
Put tests at seams rather than inside implementations.

Use only seams agreed before the test.
List proposed seams and confirm them with the user before writing tests.
For each seam, give one line on defects it catches and what it misses.
Ask "What's the public interface, and which seams should we test?"
This directs effort to critical paths and complex logic rather than every possible edge case.

In an unattended run, take seams from the plan or ticket.
Ask only when no seam is agreed and the user is available.
<!-- ‹guest · 2026-11-23› -->

If the interface shape or seam placement is undecided, load `astack-codebase-design`.
Use its Module, Interface, Depth, Seam, Adapter, Leverage and Locality vocabulary.
Consult it as a reference rather than run it as a separate work session.

## Anti-patterns

- An implementation-coupled test mocks internal collaborators, calls private methods or verifies through a side channel. Direct database queries can bypass the tested interface. If behavior is unchanged but a refactor breaks the test, inspect that coupling.
- A tautological assertion computes its expectation the same way as production. Examples include `expect(add(a, b)).toBe(a + b)`, a manually derived equivalent snapshot, or a constant compared with itself. Use an independent known-good literal, worked example or specification as the expected result.
- Horizontal slicing writes all tests before all implementation. It commits to imagined structure before feedback from real behavior. Use vertical slices instead. Write one test, implement it, then use that result to choose the next test.

## Rules of the loop

- Write and run the failing test before the code. Add only enough implementation to pass. Do not anticipate future tests or features.
- Use one seam, one test and one minimal implementation in each cycle.
- Keep refactoring outside this loop. It belongs to review with `astack-code-review`, after the red and green implementation cycle.

این نسخه با نشانه‌گذاری اختصاصی حساب شما نمایش داده می‌شود. برای نصب سریع، به تب نصب و راه‌اندازی بروید.

مهارت‌های مشابه و پیشنهادی

مشاهدهٔ همه ←
کیفیت کد و تست ✦ Pro
REA CI and tests audit
«REA CI and tests audit» دستورالعمل دقیقی برای «نوشتن و اجرای تست خودکار» در اختیار دستیار هوش مصنوعی می‌گذارد تا نتیجه، به‌جای پاسخ ک…
★ ۴۷۴,۰۸۴ کیفیت ۹۱/۱۰۰ ۱۱ ساعت پیش
تاییدشده
Claude / Claude CodeOpenAI CodexMCP
کیفیت کد و تست ✦ Pro
Finishing a Development Branch
این مهارت با نام «Finishing a Development Branch» تجربهٔ یک کاربلد در کیفیت کد و تست را کنار دستیار شما می‌گذارد؛ کافی است درخواست بده…
★ ۳۲۴,۲۹۰ کیفیت ۹۴/۱۰۰ ۷ ساعت پیش
تاییدشده
Claude / Claude Code
کیفیت کد و تست ✦ Pro
Code Review Reception
اگر روی کیفیت کد و تست کار می‌کنید، «Code Review Reception» بخشی از کار را از دوش شما برمی‌دارد: «بازنویسی و تمیزسازی کد (Refactoring)…
★ ۳۲۴,۲۹۰ کیفیت ۹۴/۱۰۰ ۷ ساعت پیش
تاییدشده
Claude / Claude Code
کیفیت کد و تست ✦ Pro
Requesting Code Review
برای کارهای کیفیت کد و تست، «Requesting Code Review» یک راهنمای کوتاه و روشن است: مسیر «مدیریت هوشمند حافظه و کانتکست» را مشخص می‌کند …
★ ۳۲۴,۲۹۰ کیفیت ۹۴/۱۰۰ ۷ ساعت پیش
تاییدشده
Claude / Claude Code
کیفیت کد و تست ✦ Pro
Test-Driven Development (TDD)
این مهارت با نام «Test-Driven Development (TDD)» تجربهٔ یک کاربلد در کیفیت کد و تست را کنار دستیار شما می‌گذارد؛ کافی است درخواست بدهی…
★ ۳۲۴,۲۹۰ کیفیت ۹۴/۱۰۰ ۷ ساعت پیش
تاییدشده
Claude / Claude Code
کیفیت کد و تست ✦ Pro
Skill Creator
اگر روی کیفیت کد و تست کار می‌کنید، «Skill Creator» بخشی از کار را از دوش شما برمی‌دارد: «هماهنگی عامل‌ها و ابزارهای MCP» را با همان ت…
★ ۱۹۸,۷۹۴ کیفیت ۹۲/۱۰۰ ۲۱ ساعت پیش
تاییدشده
Claude / Claude Code