Automatically generate test scaffolding when user writes new code without tests or mentions needing tests. Supports unit, integration, e2e, and data tests for PHP and JavaScript. Invoke when user mentions "tests", "testing", "coverage", "write tests", or shows new untested code.
Automatically generates test scaffolding when you write new code or mention needing tests. It triggers on phrases like "I need tests" or "no tests yet," analyzing your code to create unit, integration, or e2e tests for PHP and JavaScript with proper structure and mocks.
/plugin marketplace add kanopi/cms-cultivator/plugin install cms-cultivator@claude-toolboxThis skill inherits all available tools. When active, it can use any tool Claude has access to.
templates/e2e-tests.mdtemplates/integration-tests.mdtemplates/unit-tests.mdAutomatically generate test scaffolding for untested code.
Activate this skill when the user:
Identify:
Unit Tests - For isolated logic:
Integration Tests - For component interaction:
E2E Tests - For user workflows:
Complete test templates are available for reference:
Use these templates as starting points, adapting for the specific code being tested.
Generate basic test structure first:
For each public method:
Identify what needs mocking:
Check:
When user shows a class with 2-3 methods:
Example Response:
"I'll generate PHPUnit tests for your UserManager class.
I see 3 public methods:
- getUser() - retrieves user data
- createUser() - creates new user
- deleteUser() - removes user
I'll create:
- Unit tests for getUser() (no database needed)
- Integration tests for createUser() and deleteUser() (require database)
[Generates test file with 6-8 test methods covering happy paths,
error cases, and edge cases]
This gives you ~80% coverage to start."
When user shows WordPress function using WP APIs:
Example Response:
"For WordPress functions using WP_Query, you'll want an integration test.
I'll generate a WP_UnitTestCase test that:
1. Creates test posts using the factory
2. Calls your function
3. Verifies the query results
4. Cleans up automatically in tearDown()
[Generates test code]
The test uses wp_insert_post() to create test data."
When user shows Drupal service with dependencies:
Example Response:
"I'll generate unit tests for your DataProcessor service.
I see it depends on:
- EntityTypeManagerInterface
- LoggerInterface
I'll:
1. Create mocks for these dependencies
2. Test each public method in isolation
3. Verify interactions with dependencies
4. Add @covers annotations for coverage tracking
[Generates test file with mocked dependencies]
This keeps tests fast by avoiding database calls."
When user shows JS function or React component:
This skill complements the /test-generate slash command:
This Skill: Automatically triggered during conversation
/test-generate Command: Explicit batch generation
testCreateUserWithValidData() not testCreateUser()Example 1: Simple class
User: "I wrote this UserManager class, need tests"
[Shows class with 3 methods]
Skill: "I'll generate PHPUnit tests for your UserManager class.
I see 3 public methods: createUser(), getUser(), deleteUser().
I'll create tests for the happy path and error cases for each.
[Generates test file]
This gives you 80% coverage to start. You may want to add edge case
tests for boundary conditions."
Example 2: WordPress function
User: "How do I test this WordPress function?"
[Shows custom function that uses WP_Query]
Skill: "For WordPress functions using WP_Query, you'll want an
integration test. I'll generate a WP_UnitTestCase test that:
1. Creates test posts using the factory
2. Calls your function
3. Verifies the query results
[Generates test code]
The test uses wp_insert_post() to create test data, then cleans up
automatically in tearDown()."
Example 3: React component
User: "Need tests for this React component"
[Shows UserProfile component]
Skill: "I'll create React Testing Library tests for your UserProfile component.
I see it:
- Displays user data from props
- Has edit button that calls onEdit callback
- Shows loading state
I'll generate tests for:
1. Rendering with user data
2. Clicking edit button
3. Loading state display
[Generates test file using React Testing Library]
These tests verify the component behavior from a user perspective."
Don't. Test public interface instead. If private method needs testing, consider extracting to separate class.
// Avoid static methods when possible
// If you must, test directly
$result = MyClass::staticMethod($input);
$this->assertEquals($expected, $result);
// Use transactions for rollback
protected function setUp(): void {
parent::setUp();
$this->database->beginTransaction();
}
protected function tearDown(): void {
$this->database->rollbackTransaction();
parent::tearDown();
}
it('fetches user data', async () => {
const user = await fetchUser(123);
expect(user.name).toBe('John Doe');
});
// Or with promises
it('fetches user data', () => {
return fetchUser(123).then(user => {
expect(user.name).toBe('John Doe');
});
});
Drupal\Tests\mymodule\Unittest_method_name()$this->assertIsArray()This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.