flaky-fix
БесплатноБез исполняемых скриптовНе проверенSuggest and apply fixes for flaky tests based on detected patterns. Use after flaky-detect identifies unreliable tests that need repair.
от jmagly★ 233 звезды на GitHubОб этом скилле
Flaky Fix Skill
Output template
Required for the human-readable failure, fix and regression verification report: @${CLAUDE_PLUGIN_ROOT}/templates/ci-failure-report.md. Fill every required section; explain non-applicable fields and unrun checks.
Purpose
Analyze flaky test patterns and suggest or auto-apply fixes. Based on FlakyFix research showing LLMs can automatically repair flaky tests with targeted prompts.
Research Foundation
| Finding | Source | Reference |
|---|---|---|
| LLM Auto-repair | FlakyFix (2023) | arXiv:2307.00012 - 70%+ success rate |
| Flaky Taxonomy | Google (2016) | Flaky Tests Study |
| Pattern-based Fixes | FlaKat (2024) | arXiv:2403.01003 |
When This Skill Applies
- After
flaky-detectidentifies flaky tests - User asks to "fix flaky test" or "make test reliable"
- CI is failing intermittently on specific tests
- Test marked as flaky needs repair
Trigger Phrases
| Natural Language | Action |
|---|---|
| "Fix this flaky test" | Analyze and suggest fix |
| "Make this test reliable" | Apply deterministic patterns |
| "Why is this test flaky?" | Root cause analysis + fix |
| "Auto-fix flaky tests" | Batch fix safe patterns |
| "Remove timing dependency" | Specific timing fix |
Fix Patterns by Category
1. Timing Issues (45% of flaky tests)
Problem: Uses Real Time
// FLAKY: Time-dependent
it('should expire after 1 hour', () => {
const token = createToken();
expect(token.expiresAt).toBeGreaterThan(Date.now());
});
Fix: Mock Time
// FIXED: Mocked time
it('should expire after 1 hour', () => {
const fixedTime = new Date('2024-01-01T00:00:00Z');
vi.setSystemTime(fixedTime);
const token = createToken();
expect(token.expiresAt).toBe(fixedTime.getTime() + 3600000);
vi.useRealTimers();
});
Problem: Explicit Sleep/Delay
// FLAKY: Arbitrary delay
it('should complete async operation', async () => {
startAsyncOperation();
await sleep(100); // Race condition!
expect(result).toBeDefined();
});
Fix: Proper Async Handling
// FIXED: Wait for actual completion
it('should complete async operation', async () => {
const result = await startAsyncOperation();
expect(result).toBeDefined();
});
// Or use waitFor for DOM
it('should show loading state', async () => {
render(<Component />);
await waitFor(() => {
expect(screen.getByText('Loaded')).toBeInTheDocument();
});
});
2. Async Issues (25% of flaky tests)
Problem: Missing Await
// FLAKY: Promise not awaited
it('should fetch data', () => {
const promise = fetchData();
promise.then(data => {
expect(data).toBeDefined(); // May not run before test ends
});
});
Fix: Proper Async/Await
// FIXED: Awaited promise
it('should fetch data', async () => {
const data = await fetchData();
expect(data).toBeDefined();
});
Problem: Race Condition
// FLAKY: Order not guaranteed
it('should process items', async () => {
const results = [];
items.forEach(async item => {
results.push(await process(item));
});
expect(results.length).toBe(3); // Race!
});
Fix: Sequential or Parallel Await
// FIXED: Guaranteed order
it('should process items', async () => {
const results = await Promise.all(
items.map(item => process(item))
);
expect(results.length).toBe(3);
});
3. Test Order Dependencies (20% of flaky tests)
Problem: Shared State
// FLAKY: Shared state between tests
let counter = 0;
it('should increment', () => {
counter++;
expect(counter).toBe(1); // Fails if other test runs first
});
Fix: Test Isolation
// FIXED: Isolated state
describe('counter', () => {
let counter;
beforeEach(() => {
counter = 0; // Fresh state each test
});
it('should increment', () => {
counter++;
expect(counter).toBe(1);
});
});
4. Non-deterministic Values (10% of flaky tests)
Problem: Random/UUID Values
// FLAKY: Random ID
it('should create user with ID', () => {
const user = createUser();
expect(user.id).toBe('expected-id'); // Random!
});
Fix: Mock Random Generation
// FIXED: Deterministic ID
it('should create user with ID', () => {
vi.mock('uuid', () => ({
v4: () => 'test-uuid-1234'
}));
const user = createUser();
expect(user.id).toBe('test-uuid-1234');
});
5. Environment Dependencies (15% of flaky tests)
Problem: Network Calls
// FLAKY: Real network
it('should fetch from API', async () => {
const data = await fetch('https://api.example.com/data');
expect(data).toBeDefined(); // Network failures!
});
Fix: Mock Network
Установить flaky-fix в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл flaky-fix?
Suggest and apply fixes for flaky tests based on detected patterns. Use after flaky-detect identifies unreliable tests that need repair.
Как установить скилл flaky-fix?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл flaky-fix запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic