Test agent

From oyi77/1ai-skills · View interactive version

Test agent is an AI agent skill from the GitHub repository oyi77/1ai-skills. Use when writing comprehensive test suites covering happy paths, error paths, edge cases, and integration points.

How to use this skill

Skill file

Overview

This agent writes comprehensive test suites that defend observable contracts and fail on plausible bugs. Use it to close coverage on a changed module or to convert a manual reproduction into a regression test. It follows the project's test conventions and keeps the suite deterministic.

Test Agent

Quick Reference — see parent for full agent ecosystem.

The Test Agent writes and maintains test suites that cover not just happy paths but error paths, edge cases, and integration contracts. It analyzes existing code to identify coverage gaps, generates tests that fail on plausible bugs (not trivial pass-throughs), and enforces coverage thresholds across the codebase. Its philosophy: a test that cannot fail on a real bug is worse than no test — it creates false confidence.

When Not to Use

Dependencies

Commands

# Refer to the skill's usage section for specific commands
# Adapt these to your workflow

Key Responsibilities

Code Example

"""Minimal test agent pattern — analyze coverage and generate tests."""

import json, sys
from pathlib import Path

def analyze_coverage(source_path: str, test_path: str) -> dict:
    """Identify uncovered functions and generate skeleton tests."""
    source = Path(source_path)
    tests = Path(test_path)

    source_funcs = set()
    for file in source.rglob("*.py"):
        content = file.read_text()
        for line in content.split("\n"):
            stripped = line.strip()
            if stripped.startswith("def ") and not stripped.startswith("def _"):
                name = stripped.split("(")[0].replace("def ", "")
                source_funcs.add(name)

    test_funcs = set()
    for file in tests.rglob("test_*.py"):
        content = file.read_text()
        for line in content.split("\n"):
            stripped = line.strip()
            if stripped.startswith("def test_"):
                name = stripped.split("(")[0].replace("def ", "")
                test_funcs.add(name)

    uncovered = source_funcs - test_funcs

    return {
        "source_functions": sorted(source_funcs),
        "test_functions": sorted(test_funcs),
        "uncovered": sorted(uncovered),
        "coverage_pct": round(len(test_funcs) / max(len(source_funcs), 1) * 100, 1),
        "recommendations": [f"Add test for {fn}" for fn in sorted(uncovered)[:10]]
    }

if __name__ == "__main__":
    result = analyze_coverage(sys.argv[1], sys.argv[2])
    print(json.dumps(result, indent=2))

Checklist

Workflow

  1. Identify the task or trigger.
  2. Prepare inputs and configure parameters.
  3. Execute the core routine.
  4. Verify the output against expected results.
  5. Iterate based on feedback or new data.

Verification

Anti-Rationalization Table

| Rationalization | Reality |

|---|---|

| "I know this code is correct, it does not need tests" | The code you are surest about is where the most expensive bugs hide — subconscious assumptions are the blindest spots |

| "The test agent writes trivial tests" | A test covering only the happy path creates false confidence. Demand tests that fail on real edge cases |

| "We have 90% line coverage, we are fine" | Line coverage without branch measurement misses entire code paths (e.g., error handlers that never run in CI) |

When to Use

Use when adding new features (TDD), fixing bugs (regression tests), merging refactored code (behavior preservation), onboarding onto an unfamiliar module (document contract via tests), or any time coverage drops below the team threshold. Do NOT use for throwaway scripts, prototype code with a planned rewrite, or third-party libraries where upstream tests already cover the integration surface.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.