# Lock Tests First

> Explicit-invocation workflow for test-first implementation that defines behavior, proves new tests fail correctly, protects those tests from implementation-time edits, implements production code, and verifies the final red-to-green result. Use only when the user directly invokes the lock-tests-first skill.

- **Type:** Skill
- **Install:** `agentstack add skill-himanshi-28-coding-agent-skills-lock-tests-first`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [himanshi-28](https://agentstack.voostack.com/s/himanshi-28)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [himanshi-28](https://github.com/himanshi-28)
- **Source:** https://github.com/himanshi-28/coding-agent-skills/tree/main/skills/lock-tests-first

## Install

```sh
agentstack add skill-himanshi-28-coding-agent-skills-lock-tests-first
```

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

## About

# Lock Tests First

Treat tests as the behavioral contract. Do not weaken or rewrite protected tests merely to make implementation pass.

## Workflow

1. Confirm the contract.
   - Start from approved acceptance criteria or derive observable inputs, outputs, errors, state changes, and invariants.
   - Resolve any ambiguity that would change expected behavior before editing files.
2. Inspect the test system.
   - Read repository instructions, test commands, nearby tests, fixtures, and production interfaces.
   - Match existing test levels and conventions.
3. Design coverage.
   - Cover the happy path, meaningful boundaries, failures, regression cases, and relevant authorization or security behavior.
   - Prefer behavior-level assertions over implementation details, excessive mocks, or broad snapshots.
4. Write the contract tests only.
   - Modify only tests and the minimum test-only fixtures or infrastructure required to express the contract.
   - Do not write or change production behavior yet.
5. Prove the red state.
   - Run the smallest relevant test command.
   - Confirm each new test fails because the behavior is missing or wrong, not because of syntax, setup, import, fixture, or unrelated failures.
   - If a test passes unexpectedly, determine whether the behavior already exists or the assertion is ineffective. Do not proceed with a false red state.
6. Audit and protect the tests.
   - Check that assertions are meaningful, deterministic, and capable of detecting a wrong implementation.
   - Record the protected test paths and their exact pre-implementation diff or content hash.
   - Commit a test-only baseline only when the user requested or approved committing. Otherwise state that the freeze is procedural and keep the baseline for comparison.
7. Implement the smallest production change.
   - Do not modify protected tests, their expected values, or test selection.
   - If a protected test is genuinely incorrect, stop and explain the flaw; obtain approval before changing the contract.
8. Prove the green state.
   - Run the focused tests, then relevant surrounding tests and available type, lint, or build checks in proportion to risk.
   - Compare protected tests to the baseline and confirm they were not altered during implementation.
9. Review the result.
   - Inspect the production diff for overfitting, hard-coded test values, bypassed code paths, weakened validation, or unrelated changes.

## Output

Report the red evidence, protected test files, implementation summary, green evidence, broader checks, and anything not verified. Never report success from a passing test whose pre-implementation failure was not established. Use the `review-changes` skill before packaging commits.

## Source & license

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

- **Author:** [himanshi-28](https://github.com/himanshi-28)
- **Source:** [himanshi-28/coding-agent-skills](https://github.com/himanshi-28/coding-agent-skills)
- **License:** MIT

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-himanshi-28-coding-agent-skills-lock-tests-first
- Seller: https://agentstack.voostack.com/s/himanshi-28
- 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%.
