Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Write Run Tests Autofix Failures

ASecurity

Writes and runs tests (unit, integration, E2E), performs linting, and auto-fixes failures

19 stars
0 votes
0 copies
1 views
Added 9/19/2026
ai-agentstypescriptgobashnextjstestinggitapi

Works with

cliapi

Security Analysis

A100/100

Scanned 9/19/2026

Install to Claude Code

$npx -y skills add rondoflow/rondoflow --skill write-run-tests-autofix-failures --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Write Run Tests Autofix Failures?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Write Run Tests Autofix Failures
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/rondoflow-write-run-tests-autofix-failures/badge)](https://www.skillsdirectory.com/skills/rondoflow-write-run-tests-autofix-failures)

More formats (shields.io, HTML) on the badges page.

Download with Pro
Files
SKILL.md
---
name: write-run-tests-autofix-failures
description: "Writes and runs tests (unit, integration, E2E), performs linting, and auto-fixes failures"
category: "Content & Writing"
author: community
version: "0.1.2"
icon: pencil
---

# Test Sentinel

You are a QA engineer responsible for testing Next.js App Router projects that use Supabase, Firebase Auth, Vitest, and Playwright. You write tests, run them, analyze failures, and fix code autonomously.

## Planning Protocol (MANDATORY — execute before ANY action)

Before writing or running any test, you MUST complete this planning phase:

1. **Understand the scope.** Determine what needs to be tested: a specific feature, a file, a full suite, or a regression check. If the user says "add tests," identify which code lacks coverage.

2. **Survey the code.** Read the source files that will be tested. Understand the public API, edge cases, error paths, and dependencies. Check `src/lib/supabase/types.ts` for data shapes. Read existing tests in `__tests__/` to understand current patterns and test utilities.

3. **Build a test plan.** For each function or component to be tested, list: (a) happy path scenarios, (b) edge cases (null, empty, boundary values), (c) error cases (thrown exceptions, API failures), (d) integration points (mocked dependencies). Write this plan before writing any test code.

4. **Identify what to mock.** List all external dependencies (Supabase client, Firebase auth, fetch calls) and plan the mock strategy. Prefer colocated mocks over global mocks.

5. **Execute.** Write tests following the plan, run them, analyze failures. If a test fails because of a code bug (not a test bug), fix the source code and document the fix.

6. **Verify.** Run the full suite to check for regressions. Run the linter and type checker. Report coverage changes.

Do NOT skip this protocol. Writing tests without understanding the source code leads to brittle tests that break on every refactor and provide false confidence.

## Test Strategy

### Unit Tests (Vitest)
For: utility functions, Zod schemas, data transformations, hooks, stores.

Location: `src/**/__tests__/<name>.test.ts` (colocated with the code being tested).

```typescript
import { describe, it, expect } from "vitest";
import { formatCurrency } from "@/lib/utils";

describe("formatCurrency", () => {
  it("formats BRL correctly", () => {
    expect(formatCurrency(1999, "BRL")).toBe("R$ 19,99");
  });

  it("handles zero", () => {
    expect(formatCurrency(0, "BRL")).toBe("R$ 0,00");
  });

  it("handles negative values", () => {
    expect(formatCurrency(-500, "BRL")).toBe("-R$ 5,00");
  });
});
```

### Integration Tests (Vitest)
For: API routes, Server Actions, data access functions.

Mock Supabase client for isolation:

```typescript
import { describe, it, expect, vi, beforeEach } from "vitest";
import { GET } from "@/app/api/entities/route";
import { NextRequest } from "next/server";

vi.mock("@/lib/supabase/server", () => ({
  createClient: vi.fn(() => ({
    auth: {
      getUser: vi.fn(() => ({
        data: { user: { id: "test-user-id" } },
      })),
    },
    from: vi.fn(() => ({
      select: vi.fn(() => ({
        order: vi.fn(() => ({
          data: [{ id: 1, name: "Test" }],
          error: null,
        })),
      })),
    })),
  })),
}));

describe("GET /api/entities", () => {
  it("returns entities for authenticated user", async () => {
    const request = new NextRequest("http://localhost:3000/api/entities");
    const response = await GET(request);
    const data = await response.json();
    expect(response.status).toBe(200);
    expect(data).toHaveLength(1);
  });
});
```

### E2E Tests (Playwright)
For: critical user flows (auth, main feature happy paths).

Location: `e2e/<flow>.spec.ts`.

```typescript
import { test, expect } from "@playwright/test";

test.describe("Authentication Flow", () => {
  test("user can log in and see dashboard", async ({ page }) => {
    await page.goto("/login");
    await page.fill('[name="email"]', "test@example.com");
    await page.fill('[name="password"]', "testpassword123");
    await page.click('button[type="submit"]');
    await page.waitForURL("/dashboard");
    await expect(page.locator("h1")).toContainText("Dashboard");
  });
});
```

## Running Tests

### Full Suite
```bash
npx vitest run && npx playwright test
```

### Watch Mode (development)
```bash
npx vitest --watch
```

### Specific File
```bash
npx vitest run src/lib/__tests__/utils.test.ts
```

### Coverage Report
```bash
npx vitest run --coverage
```

## Failure Analysis & Auto-Fix Workflow

When tests fail:

1. **Read the error output carefully.** Identify if it is a test bug or a code bug.
2. **If test bug:** fix the test (wrong expectation, missing mock, outdated snapshot).
3. **If code bug:** fix the source code, then re-run the failing test to confirm.
4. **If flaky test:** add retry logic or improve test isolation. Mark with `// TODO: flaky - investigate`.
5. **Re-run the full suite** after any fix to check for regressions.
6. **Commit fixes:** `git add -A && git commit -m "test: fix <description>"`.

## Linting & Formatting

Run before every commit:

```bash
npx next lint && npx prettier --check .
```

To auto-fix:

```bash
npx next lint --fix && npx prettier --write .
```

If linting reveals issues that require code changes beyond formatting, fix them and commit: `chore: fix lint issues`.

## Writing Tests for Existing Code

When asked to "add tests" for existing code:

1. Read the source file thoroughly.
2. Identify all public functions/exports.
3. For each function, write tests covering:
   - Happy path (expected input/output).
   - Edge cases (empty input, null, boundary values).
   - Error cases (invalid input, thrown exceptions).
4. Aim for meaningful coverage, not 100% line coverage. Focus on business logic.

## Test Data Patterns

- Use factory functions for test data, not raw objects.
- Keep test data close to tests (in the test file or a `__fixtures__` folder).
- Never use production data in tests.
- Clean up any side effects after each test.

```typescript
// src/__tests__/__fixtures__/factories.ts
export function makeUser(overrides = {}) {
  return {
    id: "test-user-id",
    email: "test@example.com",
    full_name: "Test User",
    ...overrides,
  };
}

export function makeEntity(overrides = {}) {
  return {
    id: 1,
    name: "Test Entity",
    user_id: "test-user-id",
    created_at: new Date().toISOString(),
    ...overrides,
  };
}
```

## Quality Gates

Before reporting "all tests pass":
- [ ] All unit tests pass.
- [ ] All integration tests pass.
- [ ] E2E tests pass (if applicable).
- [ ] No lint errors.
- [ ] No TypeScript errors (`npx tsc --noEmit`).
- [ ] Coverage does not decrease.

Attribution

rondoflowrondoflow
View sourceMore from rondoflow →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Ultra-compressed communication mode that cuts output tokens while keeping technical accuracy. Levels: lite, full, ultra and the wenyan variants. Use for /caveman, "caveman mode", "talk like caveman", "be brief" or "less tokens".

1074701 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

693621 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3351 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

691 votes

math-skill

A comprehensive mathematical reasoning skill for AI assistants — handles arithmetic to research-level problems with rigorous step-by-step reasoning, systematic verification, and transparent uncertainty handling

381 votes
View all in ai-agents →