# Test Fix Verify

> Run tests, fix failures, and re-run until tests pass. Use when the user provides a test command and wants the agent to make changes and verify by re-running tests until they pass.

- Skill: `re-1th02/test-fix-verify` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add re-1th02/test-fix-verify`
- Raw SKILL.md: https://api.skillmd.com/api/skills/re-1th02/test-fix-verify/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: re-1th02 (https://skillmd.com/u/re-1th02)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/re-1th02/test-fix-verify

---


# Test–Fix–Verify Workflow

When the user gives you **workflow: test-fix-verify**, a **test command**, and **context**, follow the steps below.

## Input

- **Test command**: The exact command to run tests (e.g. `python3 test.py`, `pytest`, `npm test`).
- **Context**: Context of the task (used for alembic revision message and for making changes).

## Workflow

```
Task progress:
- [ ] Setup: run pipenv shell
- [ ] Step 1: Run tests
- [ ] Step 2: If new alembic file needed? No → Step 8
- [ ] Step 3: alembic revision -m <context> (if error → end)
- [ ] Step 4: Edit alembic file if required (if no changes → Step 8)
- [ ] Step 5: alembic upgrade head (if error → end)
- [ ] Step 6: alembic downgrade -1 (if error → end)
- [ ] Step 7: alembic upgrade head (if error → end)
- [ ] Step 8: Make changes to relevant files for the task (add debug logs if required)
- [ ] Step 9: Run tests → if passed → Step 10; if failed → Step 4
- [ ] Step 10: Remove/clear any debug logs added by the agent, then stop
```

### Setup: run pipenv shell

Before running any tests or alembic:

1. **Activate Pipenv**:
   ```bash
   pipenv shell
   ```
   Run all commands in that shell. If the agent cannot keep a shell session, use `pipenv run <command>`.

### Step 1: Run tests

Run the user's test command (inside the Pipenv environment).

- **If tests pass** → End. Report success.
- **If tests fail** → Proceed to Step 2.

### Step 2: Check if new alembic revision is needed

Determine whether the task requires **database schema changes** (new tables, columns, indexes, etc.).

- **If no new alembic file is needed** → Skip to **Step 8**.
- **If a new alembic revision is needed** → Proceed to Step 3.

### Step 3: Create alembic revision

Run:

```bash
alembic revision -m "<context>"
```

Use the user's **context** as the message (e.g. `add user role column`).

- **If the command errors** → End. Report the error.
- **If it succeeds** → Proceed to Step 4.

### Step 4: Edit the new alembic file (if required)

Open the newly created revision file in `alembic/versions/` and add or adjust `upgrade()` and `downgrade()` logic as needed for the database change.

- **If no edits are required** → Skip to **Step 8**.
- **If you made edits** → Proceed to Step 5.

### Step 5: Apply upgrade

Run:

```bash
alembic upgrade head
```

- **If it errors** → End. Report the error.
- **If it succeeds** → Proceed to Step 6.

### Step 6: Test downgrade

Run:

```bash
alembic downgrade -1
```

- **If it errors** → End. Report the error.
- **If it succeeds** → Proceed to Step 7.

### Step 7: Re-apply upgrade

Run:

```bash
alembic upgrade head
```

- **If it errors** → End. Report the error.
- **If it succeeds** → Proceed to Step 8.

### Step 8: Make changes for the task

Edit the relevant application files (models, services, APIs, etc.) to implement the task. Use the user's **context** to guide what to change.

**Add debug logs for yourself if required** (e.g. `print`, `logger.debug`, or temporary logging) to help verify behavior while developing. Track where you added them so they can be removed in Step 10.

When done, proceed to Step 9.

### Step 9: Run tests

Run the user's test command again.???????????????????????

- **If tests pass** → Proceed to **Step 10**.
- **If tests fail** → Go back to **Step 4** (revisit the alembic file or migration logic if the failure is migration-related; otherwise fix the application code and re-run tests from Step 9 as needed). Repeat until tests pass or you hit a blocking error.

### Step 10: Remove debug logs and stop

Remove and clear **any debug logs added by the agent** in Step 8 (e.g. temporary `print` statements, `logger.debug` calls, or other ad-hoc logging). Leave the code in a clean state with no debug-only output.

Then **stop** and report success.

## Rules

- Use the **exact** test command the user provided.
- **Do not edit the test script** (the test file(s) run by the test command). Fix application code, fixtures, or migrations only.
- Use the user's **context** as the argument to `alembic revision -m "<context>"`.
- On any alembic command error in steps 3, 5, 6, or 7, **end** and report the error; do not continue the workflow.
- When tests pass at Step 9, continue to Step 10. After Step 10 (debug logs removed), stop and confirm.

