Skip to content

feat: add opsx:tdd skill — TDD gate between propose and apply#1068

Open
yuritoledo wants to merge 2 commits into
Fission-AI:mainfrom
yuritoledo:yuritoledo/opsx-tdd-skill
Open

feat: add opsx:tdd skill — TDD gate between propose and apply#1068
yuritoledo wants to merge 2 commits into
Fission-AI:mainfrom
yuritoledo:yuritoledo/opsx-tdd-skill

Conversation

@yuritoledo
Copy link
Copy Markdown

@yuritoledo yuritoledo commented May 7, 2026

Summary

  • Adds opsx/specs/opsx-tdd-skill/spec.md — BDD spec for a new /opsx:tdd skill
  • Updates docs/opsx.md — adds /opsx:tdd to the commands reference table

What is opsx:tdd?

A TDD gate that sits between opsx:propose and opsx:apply:

opsx:propose → [proposal, design, tasks, tests.md] → opsx:tdd → opsx:apply

opsx:propose gains a tests.md artifact

After all applyRequires artifacts are done, opsx:propose generates tests.md — a human-readable spec of what to test, derived from BDD scenarios in proposal.md/design.md. No user input needed; it's a mechanical extraction pass.

opsx:tdd writes failing test skeletons

Reads tests.md, writes one it() block per scenario with forced RED (expect(true).toBe(false)). Runs bun test --run to confirm RED. Marks the tests artifact done.

Real assertions are intentionally deferred to opsx:apply (GREEN phase) — the component doesn't exist yet at TDD time, so writing real assertions would fail with "module not found", indistinguishable from a broken test.

opsx:apply gains a soft guard

If tests.md exists but the tests artifact isn't done, opsx:apply warns and prompts before proceeding. Fully backward compatible — no tests.md = silent pass-through.

Test plan

  • Review BDD scenarios in openspec/specs/opsx-tdd-skill/spec.md for completeness
  • Verify commands table in docs/opsx.md renders correctly
  • Confirm scenario coverage matches the design (propose generates tests.md, tdd writes code, apply guards)

Summary by CodeRabbit

  • New Features

    • Introduced /opsx:tdd command to enforce test-driven development. Generates failing test skeletons, validates test execution, and manages test status throughout the workflow.
  • Documentation

    • Added detailed specification for the TDD command, including behavioral requirements, error handling, and integration points with existing operations.

@yuritoledo yuritoledo requested a review from TabishB as a code owner May 7, 2026 14:35
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR introduces the /opsx:tdd skill specification, a TDD gate that verifies failing tests exist before applying changes. It defines how /opsx:propose generates test files with automated test cases, how /opsx:tdd validates those tests are RED, and how /opsx:apply guards change application with TDD verification.

Changes

OPSX TDD Skill Introduction

Layer / File(s) Summary
TDD Skill Specification
openspec/specs/opsx-tdd-skill/spec.md
Defines /opsx:tdd execution flow: warns when tests.md is missing or has no automatable scenarios; generates failing test skeletons with expect(true).toBe(false); runs bun test --run to verify RED state; warns on unexpected immediate passes; marks tests artifact done via openspec done tests --change "<name>"; specifies appending it() blocks into existing describe blocks without duplication.
Propose: Test Generation
openspec/specs/opsx-tdd-skill/spec.md
/opsx:propose must generate tests.md after required apply inputs complete, with ## Automated section from BDD scenarios/acceptance criteria or ## Manual-only section when none exist; includes deterministic File: path derivation rules for page components vs non-page sources; produces "Created tests.md" progress message; no user prompting during generation.
Apply: TDD Guard Gate
openspec/specs/opsx-tdd-skill/spec.md
/opsx:apply guards change application: proceeds silently if tests.md absent; proceeds if tests.md artifact status is "done"; warns and prompts user if status is incomplete; proceeds silently if tests artifact is not in change schema.
Command Documentation
docs/opsx.md
Commands table for expanded OPSX workflow adds /opsx:tdd entry describing it as a TDD gate that writes failing tests from tests.md.

Sequence Diagram

sequenceDiagram
  participant User
  participant Propose as /opsx:propose
  participant Apply as /opsx:apply
  participant TDD as /opsx:tdd
  participant TestFile as tests.md
  
  User->>Propose: invoke with BDD criteria
  Propose->>TestFile: generate with Automated/Manual sections
  Propose->>User: "Created tests.md"
  
  User->>Apply: invoke change
  Apply->>TestFile: check artifact status
  alt tests artifact not present or done
    Apply->>User: proceed silently
  else tests status incomplete
    Apply->>User: warn and prompt
    alt user agrees
      Apply->>TDD: invoke TDD verification
      TDD->>TestFile: generate failing skeletons
      TDD->>TDD: run bun test --run
      TDD->>TDD: verify RED state
      TDD->>TestFile: mark artifact done
      TDD->>User: complete
    else user declines
      Apply->>User: cancel
    end
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • TabishB

Poem

🐰 With tests that fail before they rise,
TDD gates keep code precise,
Propose and verify each day,
Red to green lights show the way! 🚦

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: introducing a new /opsx:tdd skill that serves as a TDD gate between propose and apply steps.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@openspec/specs/opsx-tdd-skill/spec.md`:
- Around line 53-55: Update the spec wording to clarify that only failures
caused by the absence of the "tests" artifact in the schema are skipped
silently: modify the THEN/AND lines around the openspec command (`openspec done
tests --change "<name>"`) so they state explicitly that if the `tests` artifact
is not defined in the schema, the command should be skipped silently, but any
other error returned by `openspec done tests` must be surfaced (not suppressed).
- Around line 40-42: The current spec step that runs "bun test --run <file>" to
verify RED tests is nondeterministic; change the verification to validate each
generated it() individually by either invoking the test runner with a
name/pattern filter for each new scenario or by parsing the test runner's
output/JSON to map results back to each generated test, and then report per-test
RED/pass status along with the aggregated counts (tests written, RED count,
unexpected passes).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 422e62b0-1700-4838-ae83-cd7c4dcf95b8

📥 Commits

Reviewing files that changed from the base of the PR and between 053d8a5 and 82b4004.

📒 Files selected for processing (2)
  • docs/opsx.md
  • openspec/specs/opsx-tdd-skill/spec.md

Comment thread openspec/specs/opsx-tdd-skill/spec.md
Comment thread openspec/specs/opsx-tdd-skill/spec.md
Copy link
Copy Markdown
Collaborator

@alfred-openspec alfred-openspec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pushing on this. The TDD gate direction is real, but I would not merge this as-is because it documents /opsx:tdd before the command is implemented or registered, adds a main spec without the generated workflow/profile/schema wiring, and bakes in Bun-specific test execution plus placeholder RED tests that are not portable across projects.

I’d suggest keeping this as a design/RFC or custom schema experiment first, then landing it with the actual template, profile, schema, and runner-selection contract so users do not get a command reference that cannot run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants