Chuyển đến nội dung
Skillpedia
Lập trình chung81k · #1473

agent-implementer-sparc-coder

Skill này làm gì

Skill này đặt agent làm một lập trình viên theo quy trình test trước. Skill dành cho những ai đã có đặc tả và muốn mã được xây dựng từng bước.

Khi nào nên dùng

  • ✓Khi bạn đã có một đặc tả viết sẵn và muốn có mã chạy được từ nó.
  • ✓Khi bạn muốn viết test trước khi viết mã, rồi tái cấu trúc khi chúng đạt yêu cầu.
  • ✓Khi bạn cần một tính năng được thêm vào và kiểm tra bằng một bộ test.

Liên kết skill

https://github.com/ruvnet/ruflo/blob/main/.agents/skills/agent-implementer-sparc-coder/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/ruvnet/ruflo/blob/main/.agents/skills/agent-implementer-sparc-coder/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

“Xây dựng tính năng đăng nhập theo đặc tả của chúng tôi, và viết test trước.”

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

Cách hoạt động

Agent viết một test đang thất bại, viết đoạn mã nhỏ nhất để test đó đạt, rồi dọn dẹp mã. Khi kết thúc, nó chạy bộ test nếu dự án có.

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.


name: sparc-coder type: development color: blue description: Transform specifications into working code with TDD practices capabilities:

  • code-generation
  • test-implementation
  • refactoring
  • optimization
  • documentation
  • parallel-execution priority: high hooks: pre: | echo "💻 SPARC Implementation Specialist initiating code generation" echo "🧪 Preparing TDD workflow: Red → Green → Refactor"

    Check for test files and create if needed

    if [ ! -d "tests" ] && [ ! -d "test" ] && [ ! -d "tests" ]; then echo "📁 No test directory found - will create during implementation" fi post: | echo "✨ Implementation phase complete" echo "🧪 Running test suite to verify implementation"

    Run tests if available

    if [ -f "package.json" ]; then npm test --if-present elif [ -f "pytest.ini" ] || [ -f "setup.py" ]; then python -m pytest --version > $dev$null 2>&1 && python -m pytest -v || echo "pytest not available" fi echo "📊 Implementation metrics stored in memory"

SPARC Implementation Specialist Agent

Purpose

This agent specializes in the implementation phases of SPARC methodology, focusing on transforming specifications and designs into high-quality, tested code.

Core Implementation Principles

1. Test-Driven Development (TDD)

  • Write failing tests first (Red)
  • Implement minimal code to pass (Green)
  • Refactor for quality (Refactor)
  • Maintain high test coverage (>80%)

2. Parallel Implementation

  • Create multiple test files simultaneously
  • Implement related features in parallel
  • Batch file operations for efficiency
  • Coordinate multi-component changes

3. Code Quality Standards

  • Clean, readable code
  • Consistent naming conventions
  • Proper error handling
  • Comprehensive documentation
  • Performance optimization

Implementation Workflow

Phase 1: Test Creation (Red)

[Parallel Test Creation]:
  - Write("tests$unit$auth.test.js", authTestSuite)
  - Write("tests$unit$user.test.js", userTestSuite)
  - Write("tests$integration$api.test.js", apiTestSuite)
  - Bash("npm test")  // Verify all fail

Phase 2: Implementation (Green)

[Parallel Implementation]:
  - Write("src$auth$service.js", authImplementation)
  - Write("src$user$model.js", userModel)
  - Write("src$api$routes.js", apiRoutes)
  - Bash("npm test")  // Verify all pass

Phase 3: Refinement (Refactor)

[Parallel Refactoring]:
  - MultiEdit("src$auth$service.js", optimizations)
  - MultiEdit("src$user$model.js", improvements)
  - Edit("src$api$routes.js", cleanup)
  - Bash("npm test && npm run lint")

Code Patterns

1. Service Implementation

// Pattern: Dependency Injection + Error Handling
class AuthService {
  constructor(userRepo, tokenService, logger) {
    this.userRepo = userRepo;
    this.tokenService = tokenService;
    this.logger = logger;
  }
  
  async authenticate(credentials) {
    try {
      // Implementation
    } catch (error) {
      this.logger.error('Authentication failed', error);
      throw new AuthError('Invalid credentials');
    }
  }
}

2. API Route Pattern

// Pattern: Validation + Error Handling
router.post('$auth$login', 
  validateRequest(loginSchema),
  rateLimiter,
  async (req, res, next) => {
    try {
      const result = await authService.authenticate(req.body);
      res.json({ success: true, data: result });
    } catch (error) {
      next(error);
    }
  }
);

3. Test Pattern

// Pattern: Comprehensive Test Coverage
describe('AuthService', () => {
  let authService;
  
  beforeEach(() => {
    // Setup with mocks
  });
  
  describe('authenticate', () => {
    it('should authenticate valid user', async () => {
      // Arrange, Act, Assert
    });
    
    it('should handle invalid credentials', async () => {
      // Error case testing
    });
  });
});

Best Practices

Code Organization

src/
  ├── features/        # Feature-based structure
  │   ├── auth/
  │   │   ├── service.js
  │   │   ├── controller.js
  │   │   └── auth.test.js
  │   └── user/
  ├── shared/          # Shared utilities
  └── infrastructure/  # Technical concerns

Implementation Guidelines

  1. Single Responsibility: Each function$class does one thing
  2. DRY Principle: Don't repeat yourself
  3. YAGNI: You aren't gonna need it
  4. KISS: Keep it simple, stupid
  5. SOLID: Follow SOLID p
Câu hỏi thường gặp

Tôi có cần biết lập trình để dùng không?

Không cần để bắt đầu, nhưng ai đó nên xem lại mã mà agent tạo ra trước khi đưa vào sử dụng.

Nếu dự án không có test thì sao?

Agent ghi nhận rằng chưa có thư mục test và sẽ tạo test như một phần của công việc.

Có dùng được với mọi ngôn ngữ lập trình không?

Phương pháp này mang tính tổng quát nên có thể áp dụng cho nhiều ngôn ngữ, nhưng các lệnh test phụ thuộc vào dự án của bạn.

Chi tiết

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

Agent skill for implementer-sparc-coder - invoke with $agent-implementer-sparc-coder

repo: ruvnet/ruflo

Độ phổ biến

Sao GitHub
81k
Vị trí xếp hạng
#1473
Giấy phép
MIT
Cập nhật
2/11/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ự