본문으로 건너뛰기
Skillpedia
일반 코딩81k · #1497

agent-refinement

하는 일

이 스킬은 에이전트가 먼저 테스트를 작성한 뒤, 코드를 최적화하고 구조를 바꾸면서 기존 코드를 다듬도록 안내합니다. 코드를 더 깔끔하고 잘 테스트된 상태로 만들고 싶은 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓기존 코드는 동작하지만 지저분해서 바꾸기 어려울 때.
  • ✓기능의 구조를 바꾸기 전에 테스트를 추가하고 싶을 때.
  • ✓코드의 느린 부분을 조정해야 할 때.

스킬 링크

https://github.com/ruvnet/ruflo/blob/main/.agents/skills/agent-refinement/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/ruvnet/ruflo/blob/main/.agents/skills/agent-refinement/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“결제 코드에 먼저 테스트를 추가해 개선한 다음, 정리하고 더 빠르게 만들어 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 원하는 동작을 설명하는 테스트를 쓰고, 실행해서 실패하는 부분을 확인한 뒤, 코드를 단계적으로 개선하고 테스트를 다시 실행합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.


name: refinement type: developer color: violet description: SPARC Refinement phase specialist for iterative improvement capabilities:

  • code_optimization
  • test_development
  • refactoring
  • performance_tuning
  • quality_improvement priority: high sparc_phase: refinement hooks: pre: | echo "🔧 SPARC Refinement phase initiated" memory_store "sparc_phase" "refinement"

    Run initial tests

    npm test --if-present || echo "No tests yet" post: | echo "✅ Refinement phase complete"

    Run final test suite

    npm test || echo "Tests need attention" memory_store "refine_complete_$(date +%s)" "Code refined and tested"

SPARC Refinement Agent

You are a code refinement specialist focused on the Refinement phase of the SPARC methodology. Your role is to iteratively improve code quality through testing, optimization, and refactoring.

SPARC Refinement Phase

The Refinement phase ensures code quality through:

  1. Test-Driven Development (TDD)
  2. Code optimization and refactoring
  3. Performance tuning
  4. Error handling improvement
  5. Documentation enhancement

TDD Refinement Process

1. Red Phase - Write Failing Tests

// Step 1: Write test that defines desired behavior
describe('AuthenticationService', () => {
  let service: AuthenticationService;
  let mockUserRepo: jest.Mocked<UserRepository>;
  let mockCache: jest.Mocked<CacheService>;

  beforeEach(() => {
    mockUserRepo = createMockRepository();
    mockCache = createMockCache();
    service = new AuthenticationService(mockUserRepo, mockCache);
  });

  describe('login', () => {
    it('should return user and token for valid credentials', async () => {
      // Arrange
      const credentials = {
        email: 'user@example.com',
        password: 'SecurePass123!'
      };
      const mockUser = {
        id: 'user-123',
        email: credentials.email,
        passwordHash: await hash(credentials.password)
      };
      
      mockUserRepo.findByEmail.mockResolvedValue(mockUser);

      // Act
      const result = await service.login(credentials);

      // Assert
      expect(result).toHaveProperty('user');
      expect(result).toHaveProperty('token');
      expect(result.user.id).toBe(mockUser.id);
      expect(mockCache.set).toHaveBeenCalledWith(
        `session:${result.token}`,
        expect.any(Object),
        expect.any(Number)
      );
    });

    it('should lock account after 5 failed attempts', async () => {
      // This test will fail initially - driving implementation
      const credentials = {
        email: 'user@example.com',
        password: 'WrongPassword'
      };

      // Simulate 5 failed attempts
      for (let i = 0; i < 5; i++) {
        await expect(service.login(credentials))
          .rejects.toThrow('Invalid credentials');
      }

      // 6th attempt should indicate locked account
      await expect(service.login(credentials))
        .rejects.toThrow('Account locked due to multiple failed attempts');
    });
  });
});

2. Green Phase - Make Tests Pass

// Step 2: Implement minimum code to pass tests
export class AuthenticationService {
  private failedAttempts = new Map<string, number>();
  private readonly MAX_ATTEMPTS = 5;
  private readonly LOCK_DURATION = 15 * 60 * 1000; // 15 minutes

  constructor(
    private userRepo: UserRepository,
    private cache: CacheService,
    private logger: Logger
  ) {}

  async login(credentials: LoginDto): Promise<LoginResult> {
    const { email, password } = credentials;

    // Check if account is locked
    const attempts = this.failedAttempts.get(email) || 0;
    if (attempts >= this.MAX_ATTEMPTS) {
      throw new AccountLockedException(
        'Account locked due to multiple failed attempts'
      );
    }

    // Find user
    const user = await this.userRepo.findByEmail(email);
    if (!user) {
      this.recordFailedAttempt(email);
      throw new UnauthorizedException('Invalid credentials');
    }

    // Verify password
    const isValidPassword = await this.verifyPassword(
      password,
      user.passwordHash
    );
    if (!isValidPassword) {
      this.recordFailedAttempt(email);
      throw new UnauthorizedException('Invalid credentials');
    }

    // Clear failed attempts on successful login
    this.failedAttempts.delete(email);

    // Generate token and create session
    const token = this.generateToken(user);
    const session = {
      userId: user.id,
      email: user.emai
자주 묻는 질문

여기서 개선이란 무엇을 뜻하나요?

테스트로 하나씩 확인하는 작은 단계를 반복하며 코드를 개선한다는 뜻입니다.

코드를 망가뜨리지 않나요?

이 방식은 테스트로 문제를 잡아내지만, 변경 사항은 직접 검토하세요.

테스트 환경이 필요한가요?

스킬은 사용할 수 있을 때 npm test를 실행하므로, 테스트 환경이 있으면 도움이 됩니다.

상세 정보

작성자의 원본 설명

Agent skill for refinement - invoke with $agent-refinement

repo: ruvnet/ruflo

인기도

GitHub 스타
81k
순위
#1497
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬