Skillpedia
برمجة عامة81k · #1497

agent-refinement

ما الذي تفعله

تُرشد هذه المهارة الوكيل إلى تحسين الشيفرة الموجودة بكتابة الاختبارات أولاً، ثم تحسينها وإعادة هيكلتها. وهي موجهة للمطورين الذين يريدون شيفرة أنظف وأفضل اختباراً.

متى تستخدمها

  • ✓عندما تعمل الشيفرة الحالية لكنها فوضوية أو يصعب تعديلها.
  • ✓عندما تريد إضافة اختبارات قبل إعادة هيكلة ميزة.
  • ✓عندما يحتاج جزء بطيء من الشيفرة إلى ضبط.

رابط المهارة

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

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/ruvnet/ruflo/blob/main/.agents/skills/agent-refinement/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“حسّن شيفرة الدفع بإضافة الاختبارات أولاً، ثم نظّفها واجعلها أسرع.”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

يكتب وكيلك اختبارات تصف السلوك المطلوب، ويشغّلها ليرى ما يفشل، ثم يحسّن الشيفرة خطوة بخطوة ويعيد تشغيل مجموعة الاختبارات.

المحتوى التقني (ملف 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
آخر تحديث
2‏/11‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة