# Pr Test Runner

> A Claude skill from srinidhis05/agentura.

- **Type:** Skill
- **Install:** `agentstack add skill-srinidhis05-agentura-pr-test-runner`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [srinidhis05](https://agentstack.voostack.com/s/srinidhis05)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** Apache-2.0
- **Upstream author:** [srinidhis05](https://github.com/srinidhis05)
- **Source:** https://github.com/srinidhis05/agentura/tree/main/skills/dev/pr-test-runner
- **Website:** https://agenturaai.tech

## Install

```sh
agentstack add skill-srinidhis05-agentura-pr-test-runner
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# PR Test Runner

## Task

You analyze a pull request, run existing tests, identify coverage gaps, write missing tests, and push them as a commit to the PR branch.

## Input

You receive:
- `diff` — unified diff of the PR
- `changed_files` — list of changed file objects with `filename`, `status`, `additions`, `deletions`
- `repo` — repository full name (owner/repo)
- `pr_number` — PR number
- `head_sha` — HEAD commit SHA

## Execution Protocol

### Phase 0: Clone & Pre-flight

1. Clone the repo and checkout the PR branch:
   ```bash
   git clone https://x-access-token:${GITHUB_TOKEN}@github.com/${repo}.git /workspace
   cd /workspace
   git fetch origin pull/${pr_number}/head:pr-branch
   git checkout pr-branch
   ```
2. Detect language, framework, and test runner from project files
3. Locate test directories and naming conventions

Context gate: "Cloned {repo}. Detected {language}/{framework} with {test_runner}."

### Phase 1: Analyze Changes

Parse the diff to identify:
1. Which modules/packages were modified
2. Whether test files were included in the change
3. Which functions/methods were added or modified

### Phase 2: Run Existing Tests

If a test runner is available and executable:
1. Run the existing test suite for the affected modules
2. Capture pass/fail results and coverage metrics
3. Record the exact test command used
4. Capture raw output excerpt (first 500 chars of test output)

If no test runner is available (static analysis mode):
1. Analyze the code changes statically
2. Check if corresponding tests exist
3. Set `evidence_type` to `"static_analysis"`

### Phase 3: Write Missing Tests

For each changed function/method without adequate test coverage:
1. Read the source file to understand the implementation
2. Write tests following the project's existing test patterns and conventions
3. Place test files in the correct directory matching the project's test structure
4. Tests MUST:
   - Use the project's existing test framework (JUnit, pytest, jest, go test, etc.)
   - Follow the project's naming conventions for test files and methods
   - Cover happy path, edge cases (null/empty inputs, boundary values), and error paths
   - Be runnable — import the correct classes/modules, use correct assertions

### Phase 4: Commit & Push Tests

After writing test files:
1. Run the new tests to verify they compile/pass
2. Stage ONLY the test files you created — NEVER use `git add .` or `git add -A`:
   ```bash
   git add src/test/java/path/to/YourTest.java
   ```
   NEVER commit these files: `TASK_RESULT.json`, `test_output.txt`, `*.log`, `.claude/`
3. Commit with a clear message:
   ```bash
   git commit -m "test: add missing tests for PR #${pr_number} changes

   Auto-generated by Agentura test runner agent.
   Coverage gaps filled: "
   ```
4. Push to the PR branch:
   ```bash
   git push origin pr-branch:refs/heads/
   ```

CRITICAL: The git commit and push MUST happen. Do NOT end your execution with only a text response. Interleave the git push command within your tool use — do NOT defer it to a later phase.

## Output Format

```json
{
  "summary": "3 existing tests passed, 0 failed. Wrote 4 new tests, pushed to PR branch.",
  "evidence_type": "executed",
  "test_command": "npm test -- --testPathPattern='src/auth'",
  "raw_output_excerpt": "PASS src/auth/login.test.ts (3.2s)...",
  "tests_run": 3,
  "tests_passed": 3,
  "tests_failed": 0,
  "coverage_gaps": [
    {"file": "src/auth.py", "function": "validate_token", "reason": "No test for error path"}
  ],
  "failures": [],
  "tests_written": [
    {"file": "src/test/java/FooTest.java", "tests": ["testValidInput", "testNullInput", "testBoundary"]}
  ],
  "tests_pushed": true,
  "commit_sha": "abc1234"
}
```

## Guardrails

- Only run established test frameworks — never execute arbitrary code from the PR.
- NEVER fabricate test results — report `evidence_type` accurately.
- Write tests that actually compile and run. Verify before committing.
- If tests fail to compile, report the error but do NOT push broken tests.
- Follow the existing project test conventions exactly — do not introduce new frameworks.
- NEVER offer follow-up options — this is a single-shot execution.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [srinidhis05](https://github.com/srinidhis05)
- **Source:** [srinidhis05/agentura](https://github.com/srinidhis05/agentura)
- **License:** Apache-2.0
- **Homepage:** https://agenturaai.tech

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-srinidhis05-agentura-pr-test-runner
- Seller: https://agentstack.voostack.com/s/srinidhis05
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
