gen-tests

gen-tests is a command for Claude Code from alphaaiservice/cortex. It costs 29 tokens per session (641 once invoked), scanned A, original, MIT.

A tool that generates tests for a file or module, using the testing framework and patterns already present in the project. It can also find source files that do not have matching tests.

In plain words
What is it for?
Use it on a specific target or with the all-untested option to create tests for untested source files using Jest, Vitest, Pytest, JUnit, or Go testing.
Why use it?
It reduces the effort of identifying code paths, edge cases, error cases, and external dependencies that need testing. This helps add coverage while following the project's existing conventions.

Command for Claude Code

Written for Claude Code: $ARGUMENTS substitution.

Part of the cortex plugin — 43 commands, 1 MCP server shipped together

Good fit Use it on a specific target or with the all-untested option to create tests for untested source files using Jest, Vitest, Pytest, JUnit, or Go testing.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/alphaaiservice/cortex/gen-tests
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/alphaaiservice/cortex

Made for: Claude Code.

Or install cortex, the plugin that ships this one along with the rest of its 43 commands, 1 MCP server.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for gen-tests

README.md
[![agentmods](https://agentmods.dev/badge/commands/alphaaiservice/cortex/gen-tests/github.svg)](https://agentmods.dev/commands/alphaaiservice/cortex/gen-tests)
Your own site
<a href="https://agentmods.dev/commands/alphaaiservice/cortex/gen-tests"><img src="https://agentmods.dev/badge/commands/alphaaiservice/cortex/gen-tests/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for gen-tests

Your own site · 80×15
<a href="https://agentmods.dev/commands/alphaaiservice/cortex/gen-tests"><img src="https://agentmods.dev/badge/commands/alphaaiservice/cortex/gen-tests.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 29 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 641 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00029 $0.00641
Opus 5.5 $0.00012 $0.00256
Sonnet 5.5 $0.00006 $0.00128
Haiku 4.5 $0.00003 $0.00064

Measured 1mo ago against content hash 52f6c8d3ccb6, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

gen-tests scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/gen-tests.md · 90 lines

How it starts

The opening of the file, as written. The whole thing — 90 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Automated Test Generation

Generate comprehensive tests for: $ARGUMENTS

Step 1: Analyze Target

  1. Read the target file(s) specified in $ARGUMENTS
  2. If --all-untested, find all source files without corresponding test files
  3. Identify the testing framework already in use (Jest, Vitest, Pytest, JUnit, Go testing)
  4. Understand existing test patterns in the project

Step 2: Analyze Functions/Methods

For each function/method/class in the target:

  • Identify input parameters and their types
  • Map all code paths (branches, loops, early returns)
  • Identify external dependencies to mock
  • Determine expected outputs for each path
  • Find edge cases (null, empty, boundary values, overflow)

Step 3: Generate Test File

Create test file following project conventions:

Test Structure

describe('[ModuleName]', () => {
  describe('[functionName]', () => {
    // Happy path tests
    it('should [expected behavior] when [condition]', () => {})

    // Edge cases
    it('should handle empty input', () => {})
    it('should handle null/undefined', () => {})

    // Error cases
    it('should throw [ErrorType] when [condition]', () => {})

    // Boundary tests
    it('should handle maximum/minimum values', () => {})
  })
})

Test Categories to Generate

  1. Happy path — Normal expected usage (at least 2 tests per function)
  2. Edge cases — Empty, null, undefined, zero, max values
  3. Error handling — Invalid inputs, network failures, timeouts
  4. Integration — How the module interacts with dependencies
  5. Regression — Tests for any known bugs or tricky logic

Step 4: Mock Strategy

  • Use existing mock patterns from the project
  • Mock external APIs, databases, and file system
  • Create fixture files if needed
  • Use factory patterns for test data

Step 5: Verify Tests

# Run the generated tests
npm test -- --testPathPattern=[test-file] 2>&1 || pytest [test-file] -v 2>&1

Fix any failing tests. Ensure all tests pass before finishing.

Read the full file on GitHub · 90 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 90 lines · 29 tokens per session scan A 52f6c8d3ccb6

Subscribe to this mod's changes

gen-tests is a command published in the GitHub repository alphaaiservice/cortex (1 stars, last pushed 2mo ago), licensed MIT. It adds 29 tokens to every session and 641 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.