Skip to content

Feature: /opencode:test command for generating/running tests #27

@JohnnyVicious

Description

@JohnnyVicious

Motivation

A frequently requested workflow: "have OpenCode write or extend tests for this diff / this file / this module" as a first-class command, not a hand-crafted rescue prompt. This complements the existing review flow — review finds issues, test writes regression coverage.

Proposed UX

/opencode:test                          # tests for current diff
/opencode:test --path src/auth          # tests for a specific module
/opencode:test --file scripts/foo.mjs   # tests for a specific file
/opencode:test --run                    # generate, then run the test suite and iterate

Implementation sketch

  • New command plugins/opencode/commands/test.md.
  • New prompt template prompts/test.md that instructs OpenCode to: infer the test framework (Vitest/Jest/node:test/etc.) from package.json, find co-located or parallel test files, write tests matching the project's existing style, and run them when --run is set.
  • Handler builds the same git diff context as review when no --path/--file is given, then dispatches under the build agent (write-capable).
  • Returns a summary of tests written + pass/fail if --run was set.

Upstream reference

Derived from openai/codex-plugin-cc#205.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions