Chuyển đến nội dung
Skillpedia
Kiểm thử48k · #5935

tdd-workflows-tdd-green

Skill này làm gì

Công cụ này giúp viết đoạn code tối thiểu cần thiết để một test thất bại pass. Nó tập trung giải quyết vấn đề trước mắt để test bắt đầu hoạt động trở lại.

Khi nào nên dùng

  • ✓Khi một test code bị thất bại và bạn cần sửa nhanh.
  • ✓Khi bắt đầu một tính năng mới và bước đầu tiên là làm cho test pass.
  • ✓Khi bạn cần chỉ triển khai những phần thiết yếu để code hoạt động như mong đợi.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/tdd-workflows-tdd-green/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/tdd-workflows-tdd-green/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Test danh sách sản phẩm của tôi đang thất bại, hãy tạo code tối thiểu để nó pass.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ phân tích thay đổi code nhỏ nhất đáp ứng test đang lỗi. Nó áp dụng bản sửa nhỏ này và kiểm tra xem test đã pass chưa, mà không thêm độ phức tạp không cần thiết.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Green Phase: Simple function

def product_list(request): products = Product.objects.all() return JsonResponse({'products': list(products.values())})

Refactor: Class-based view

class ProductListView(View): def get(self, request): products = Product.objects.all() return JsonResponse({'products': list(products.values())})

Refactor: Generic view

class ProductListView(ListView): model = Product context_object_name = 'products'


### Express Patterns

**Inline → Middleware → Service Layer:**
```javascript
// Green Phase: Inline logic
app.post('/api/users', (req, res) => {
  const user = { id: Date.now(), ...req.body };
  users.push(user);
  res.json(user);
});

// Refactor: Extract middleware
app.post('/api/users', validateUser, (req, res) => {
  const user = userService.create(req.body);
  res.json(user);
});

// Refactor: Full layering
app.post('/api/users',
  validateUser,
  asyncHandler(userController.create)
);

Use this skill when

  • Moving from red to green in a TDD cycle
  • Implementing minimal behavior to satisfy tests
  • You want to keep implementation intentionally simple

Do not use this skill when

  • You are refactoring for design or performance
  • Tests are already passing and you need new requirements
  • You need a full architectural redesign

Instructions

  1. Review failing tests and identify the smallest fix.
  2. Implement the minimal change to pass the next test.
  3. Run tests after each change to confirm progress.
  4. Record shortcuts or debt for the refactor phase.

Safety

  • Avoid bypassing tests to make them pass.
  • Keep changes scoped to the failing behavior only.

Resources

  • resources/implementation-playbook.md for detailed patterns and examples.

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.
Câu hỏi thường gặp

“Giai đoạn green” trong TDD nghĩa là gì?

Trong TDD (Phát triển hướng kiểm thử), “giai đoạn green” là khi tất cả test trong code đều pass.

Vì sao quan trọng khi viết code tối thiểu?

Viết code tối thiểu tránh sự phức tạp không cần thiết và đảm bảo bạn giải quyết đúng vấn đề mà test chỉ ra, giúp việc bảo trì sau này dễ hơn.

Khi nào nên ngừng dùng công cụ này?

Bạn nên dừng khi các test đã pass và cần thêm tính năng mới, hoặc khi mục tiêu là cải thiện thiết kế tổng thể của code chứ không chỉ sửa một test.

Chi tiết

Mô tả gốc của tác giả

Implement the minimal code needed to make failing tests pass in the TDD green phase.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#5935
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự