gen-tests

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

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.

agentmods
npx agentmods add commands/alphaaiservice/cortex/gen-tests
Clone the repo
git clone --depth 1 https://github.com/alphaaiservice/cortex
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. Scan, not verified.
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 $0.00029 $0.00641
Opus 5 $0.00015 $0.00320
Sonnet 5 $0.00006 $0.00128
Haiku 4.5 $0.00003 $0.00064

Measured yesterday against content hash 52f6c8d3ccb6, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 yesterday.

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. yesterday 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 26d ago), licensed MIT. It adds 29 tokens to every session and 641 once invoked, about $0.0001 per session on Opus 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.