From rawgentic
Create or improve a project's test suite using the WF12 14-step workflow with brainstorming-driven test strategy, context7 framework docs lookup, test harness generation, coverage gap analysis, and verified test execution. Invoke with /create-tests optionally followed by a specific file or module path. DO NOT use this skill if the user has BMAD's TEA module installed — use the TEA test workflows (bmad-testarch-*) instead. Only trigger when the user explicitly invokes /create-tests or /rawgentic:create-tests, or is working in a rawgentic-only project without BMAD.
How this skill is triggered — by the user, by Claude, or both
Slash command
/rawgentic:create-tests Optional file/module path (e.g., "src/auth/") or omit for whole projectOptional file/module path (e.g., "src/auth/") or omit for whole projectThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
<role>
Determine the active project using this fallback chain:
Level 1 -- Conversation context: If a previous /rawgentic:switch in this session set the active project, use that.
Level 2 -- Session registry: Read claude_docs/session_registry.jsonl. Grep for your session_id. If found, use the project from the most recent matching line.
Level 3 -- Workspace default: Read .rawgentic_workspace.json from the Claude root directory. If exactly one project has active == true, use it. If multiple projects are active, STOP and tell user: "Multiple active projects. Run /rawgentic:switch <name> to bind this session."
At any level:
.rawgentic_workspace.json missing -> STOP. Tell user: "No rawgentic workspace found. Run /rawgentic:new-project.".rawgentic_workspace.json malformed -> STOP. Tell user: "Workspace file is corrupted. Run /rawgentic:new-project to regenerate, or fix manually."activeProject.path may be relative (e.g., ./projects/my-app). Resolve it against the Claude root directory (the directory containing .rawgentic_workspace.json) to get the absolute path for file operations.1b. Disabled skill check: After resolving the active project, read .rawgentic_workspace.json (if not already read in step 1) and find the active project's entry.
disabledSkills array and this skill's bare name appears in it: STOP.
/rawgentic:setup or edit disabledSkills in .rawgentic_workspace.json."
Mapping: implement-feature -> bmad-dev-story, fix-bug -> bmad-dev-story, create-tests -> bmad-tea agent / bmad-testarch-* workflows, update-docs -> BMAD tech-writer.disabledSkills in .rawgentic_workspace.json to re-enable."bmadDetected is true but the project entry has no disabledSkills field: STOP. Tell user:
"BMAD detected but no skill preferences configured for [project]. Run /rawgentic:switch or /rawgentic:setup to configure."capabilities object, so all 11
workflow skills and the docs table cannot drift apart):
python3 hooks/capabilities_lib.py derive \
--config <activeProject.path>/.rawgentic.json
/rawgentic:setup). A config.version mismatch is only a stderr warning and does NOT stop the workflow.{"config": {...}, "capabilities": {...}}. Use the parsed config object and the derived capabilities object for all subsequent steps. The capabilities fields are: has_tests, test_commands, has_ci, has_deploy, deploy_method, has_database, has_docker, project_type, repo, default_branch, migration_dir. Carry these values as literals into later commands (each step is its own Bash call, so shell variables do not persist across them).All subsequent steps use config and capabilities — never probe the filesystem for information that should be in the config.
All other project-specific values come from config and capabilities loaded via the <config-loading> block.
If config loading fails, STOP and tell the user which config step failed.
WF12 terminates after test execution verification and completion summary. No auto-transition to other workflows. WF12 terminates ONLY after the completion-gate (after Step 14) passes. All steps must have markers in session notes, and the completion-gate checklist must be printed with all items passing. Per rawgentic workflow principle: before context compaction, document in `claude_docs/session_notes.md`: current step number, branch name, last commit SHA, mode (greenfield/coverage-gap), testing strategy decisions, frameworks chosen, and loop-back budget state. If test strategy decisions are ambiguous (e.g., multiple valid frameworks, unclear what to mock vs. integration test), STOP and present options to the user for resolution. The brainstorming step should surface most of these, but edge cases may appear during implementation. WF12 is language-agnostic. Use config.techStack and filesystem detection to identify the language(s), then select appropriate test frameworks. This map provides defaults — the brainstorming step (Step 2) may override these based on user preference.| Language | Default Framework | Config File | Test Pattern | Dep Install | Coverage Tool |
|---|---|---|---|---|---|
| Python | pytest | pyproject.toml / pytest.ini | test_*.py / *_test.py | pip install pytest | pytest-cov |
| JavaScript | vitest (or jest) | vitest.config.ts / jest.config.js | *.test.js / *.spec.js | npm install --save-dev | v8/istanbul |
| TypeScript | vitest (or jest) | vitest.config.ts | *.test.ts / *.spec.ts | npm install --save-dev | v8/istanbul |
| Go | go test (stdlib) | none | *_test.go | none | go test -cover |
| Rust | cargo test (stdlib) | Cargo.toml | #[cfg(test)] mod tests | none (dev-deps in Cargo.toml) | cargo-tarpaulin |
| C/C++ | GoogleTest / CTest | CMakeLists.txt | *_test.cpp | cmake FetchContent or apt | gcov/lcov |
| Shell/Bash | bats-core | none | *.bats | git clone / brew install | kcov (optional) |
| Ruby | rspec | .rspec / spec_helper.rb | *_spec.rb | gem install rspec | simplecov |
| PHP | phpunit | phpunit.xml | *Test.php | composer require --dev | phpunit --coverage |
| Java | JUnit 5 | build.gradle / pom.xml | *Test.java | gradle/maven dep | jacoco |
| Kotlin | JUnit 5 + MockK | build.gradle.kts | *Test.kt | gradle dep | jacoco |
| Swift | XCTest | Package.swift | *Tests.swift | built-in | xcodebuild |
For multi-language projects (e.g., Python backend + JavaScript frontend + shell scripts for deployment):
make test or script should run all test suites in sequenceFor shell scripts specifically:
@test blocks, run command capture, and assertionssetup() and teardown() functions, temp directory fixturesInput: Optional file/module path from user. If omitted, scope is the entire project.
PROJECT_ROOT.SCOPE = "targeted" and TARGET_PATH = <user's path>.SCOPE = "project-wide".capabilities.has_tests from config.detected_languages list.<language-framework-map>:
test_*.py, *_test.py, conftest.py*.test.js, *.spec.ts, *.test.tsx*_test.go#[cfg(test)] in source files*_test.cpp, *_test.c, test_*.cpp*.bats, test_*.sh*_spec.rb*Test.php*Test.java, *Test.ktpytest.ini, vitest.config.*, jest.config.*, playwright.config.*, .rspec, phpunit.xml, CMakeLists.txt with enable_testing(), etc.Mode: greenfield / coverage-gap Scope: project-wide / targeted () Tech stack: Existing test frameworks: <list or "none"> Test files found: <count or "none">
Loopback: None — this is the entry point.
Invoke the superpowers:brainstorming skill to collaboratively design the testing strategy with the user. The brainstorming skill will ask questions one at a time and produce a design document.
Seed the brainstorming with this context (include in your prompt to the brainstorming flow):
Topics the brainstorming should cover:
Output: A design document saved to docs/plans/YYYY-MM-DD-testing-strategy.md with the agreed testing strategy.
Loopback: None — brainstorming handles its own iteration internally.
Use the context7 MCP server to pull up-to-date documentation for the chosen test framework(s). This ensures generated tests follow current idioms rather than stale patterns from training data.
For each framework decided in Step 2:
Resolve the library ID:
Call mcp__plugin_context7_context7__resolve-library-id with the framework name (e.g., "pytest", "vitest", "jest", "playwright", "go testing").
Query relevant docs:
Call mcp__plugin_context7_context7__query-docs with the resolved library ID and targeted topics:
Extract key patterns into a working reference:
Store the extracted patterns in memory — these guide all subsequent test generation steps.
Fallback strategy when context7 lacks docs:
Some frameworks (bats-core, GoogleTest, cargo test) may not be in context7's library index. When resolve-library-id returns no match:
Loopback: None.
git status --porcelain). If dirty, ask user to commit or stash.git fetch origin.git checkout -b test/bootstrap-test-suite origin/<default_branch>git checkout -b test/improve-coverage origin/<default_branch>Loopback: None.
Greenfield mode:
For each language in detected_languages (from Step 1), set up its test infrastructure using the <language-framework-map> defaults (or overrides from the brainstorming strategy):
pip install pytest pytest-cov (or add to pyproject.toml/requirements-dev.txt)npm install --save-dev vitest @vitest/coverage-v8 (or jest, etc.)git clone https://github.com/bats-core/bats-core && ./install.sh /usr/local)gem install rspec or add to Gemfilecomposer require --dev phpunit/phpunittests/ for Python, __tests__/ or colocated for JS/TS, *_test.go alongside source for Go).test/test_helper.bash with common setup functions.test target that runs each language's tests in sequencetest scriptrun_tests.sh scriptCoverage-gap mode:
Loopback: None.
Build a map of what needs tests:
Present the test target map to the user:
Files needing tests: X Functions/methods to cover: Y Priority order: <top 5 files with reasoning>
Loopback: None.
This is the core generation step. For each test target (prioritized from Step 6):
test_*.py, *.test.ts, *_test.go)Write tests in batches — commit after each logical group (e.g., all tests for one module).
Loopback target: Steps 9 and 11 may loop back here.
Run the full test suite using the framework command:
Report to user:
Results: X passed, Y failed, Z errors Coverage: N% (if available) Duration: Xs
If all tests pass on first run, proceed to Step 10. If tests fail, proceed to Step 9.
Loopback: None.
For each failing test:
After fixing all test bugs, re-run the full suite.
Loopback: If tests still fail after fixes, loop back to Step 7 with updated understanding. Budget: max 2 iterations (Step_9_to_7). If budget exhausted, report remaining failures to user and proceed.
If coverage meets the strategy goals from Step 2, proceed to Step 11. If significant gaps remain and user wants them filled, loop back to Step 7 (uses Step_11_to_7 budget).
Loopback: Step_11_to_7: max 1 iteration.
Review the generated test suite for quality:
Present findings to user. Apply approved improvements.
Loopback: If review reveals tests that need rewriting, loop back to Step 7 (uses Step_11_to_7 budget).
Update the project config with discovered/created testing capabilities:
.rawgentic.json.testing section:
{
"testing": {
"frameworks": [
{
"name": "<framework>",
"type": "<unit|integration|e2e>",
"command": "<run command>",
"configFile": "<config file path>",
"testDir": "<test directory>"
}
]
}
}
Loopback: None.
test: bootstrap test suite with <framework>test: improve coverage for <scope>git push -u origin <branch-name>gh pr create:
## Summary
- <Mode: greenfield bootstrap / coverage improvement>
- <Framework(s) used>
- <Number of test files created/modified>
- <Coverage: X% overall>
## Test Strategy
<Link to docs/plans/YYYY-MM-DD-testing-strategy.md>
## Test Results
- Passed: X
- Failed: 0
- Coverage: X%
capabilities.has_ci), wait for CI to pass.Loopback: None.
Present final summary to user:
## WF12 Complete: Test Suite <Created / Improved>
**Mode:** greenfield / coverage-gap
**Scope:** project-wide / targeted (<path>)
**Framework:** <name>
**Tests:** X files, Y test cases
**Coverage:** Z%
**PR:** <url>
### Key Decisions (from brainstorming)
- <decision 1>
- <decision 2>
### Findings
- <any source bugs discovered>
- <any architectural concerns>
### Next Steps
- Merge PR when ready
- Consider adding CI test step if not present
- Run /rawgentic:implement-feature with TDD now that test infrastructure exists
Loopback: None.
If ANY item fails, go back and complete it before declaring "WF12 complete." You may NOT output "WF12 complete" until all items pass.
If this skill is invoked mid-conversation, detect the current state:
Announce the detected state before resuming: "Detected prior progress. Resuming at Step N."
npx claudepluginhub 3d-stories/rawgentic --plugin rawgenticCreates bite-sized, testable implementation plans from specs or requirements, with file structure and task decomposition. Activates before coding multi-step tasks.