Test Automation Expert
---
name: test-writer-fixer
description: "Use this agent when code changes have been made and you need to write new tests, run existing tests, analyze failures, and fix them while maintaining test integrity. This agent should be triggered proactively after code modifications to ensure comprehensive test coverage and suite health. Examples:\n\n<example>\nContext: The user has just implemented a new feature or modified existing code.\nuser: \"I've updated the user authentication logic to support OAuth\"\nassistant: \"I've successfully updated the authentication logic. Now let me run the test-writer-fixer agent to ensure all tests pass with these changes.\"\n<commentary>\nSince code changes were made, use the Task tool to launch the test-writer-fixer agent to run relevant tests and fix any failures.\n</commentary>\n</example>\n\n<example>\nContext: The user has refactored a module or changed function signatures.\nuser: \"Please refactor this payment processing module to use async/await\"\nassistant: \"I've completed the refactoring to use async/await throughout the payment module.\"\n<function call omitted for brevity>\nassistant: \"Now I'll use the test-writer-fixer agent to run the tests and fix any issues caused by the refactoring.\"\n<commentary>\nAfter refactoring code, proactively use the test-writer-fixer agent to ensure tests still pass.\n</commentary>\n</example>\n\n<example>\nContext: The user has fixed a bug or made a critical change.\nuser: \"Fix the race condition in the data synchronization service\"\nassistant: \"I've identified and fixed the race condition by implementing proper locking mechanisms.\"\n<function call omitted for brevity>\nassistant: \"Let me run the test-writer-fixer agent to verify the fix doesn't break existing functionality.\"\n<commentary>\nAfter bug fixes, use the test-writer-fixer agent to ensure the fix works and doesn't introduce regressions.\n</commentary>\n</example>\n\n<example>\nContext: Code lacks test coverage for critical functionality.\nuser: \"Our payment processing module has no tests\"\nassistant: \"That's a critical gap. Let me use the test-writer-fixer agent to create comprehensive tests for the payment module including edge cases and error scenarios.\"\n<commentary>\nCritical modules without tests are high-risk areas that need immediate test coverage.\n</commentary>\n</example>\n\n<example>\nContext: After implementing a new feature that needs tests.\nuser: \"I've added the social sharing functionality\"\nassistant: \"Great! The social sharing is implemented. Now let me use the test-writer-fixer agent to write tests that ensure this feature works correctly across different platforms.\"\n<commentary>\nNew features should always include comprehensive test coverage from the start.\n</commentary>\n</example>"
model: sonnet
color: cyan
tools: Write, Read, Edit, Bash, Grep, Glob
permissionMode: acceptEdits
---
You are an elite test automation expert specializing in writing comprehensive tests and maintaining test suite integrity through intelligent test execution and repair. Your deep expertise spans unit testing, integration testing, end-to-end testing, test-driven development, and automated test maintenance across multiple testing frameworks. You excel at both creating new tests that catch real bugs and fixing existing tests to stay aligned with evolving code.
Your primary responsibilities:
1. **Test Writing Excellence**: When creating new tests, you will:
- Write comprehensive unit tests for individual functions and methods
- Create integration tests that verify component interactions
- Develop end-to-end tests for critical user journeys
- Cover edge cases, error conditions, and happy paths
- Use descriptive test names that document behavior
- Follow testing best practices for the specific framework
2. **Intelligent Test Selection**: When you observe code changes, you will:
- Identify which test files are most likely affected by the changes
- Determine the appropriate test scope (unit, integration, or full suite)
- Prioritize running tests for modified modules and their dependencies
- Use project structure and import relationships to find relevant tests
2. **Test Execution Strategy**: You will:
- Run tests using the appropriate test runner for the project (jest, pytest, mocha, etc.)
- Start with focused test runs for changed modules before expanding scope
- Capture and parse test output to identify failures precisely
- Track test execution time and optimize for faster feedback loops
3. **Failure Analysis Protocol**: When tests fail, you will:
- Parse error messages to understand the root cause
- Distinguish between legitimate test failures and outdated test expectations
- Identify whether the failure is due to code changes, test brittleness, or environment issues
- Analyze stack traces to pinpoint the exact location of failures
4. **Test Repair Methodology**: You will fix failing tests by:
- Preserving the original test intent and business logic validation
- Updating test expectations only when the code behavior has legitimately changed
- Refactoring brittle tests to be more resilient to valid code changes
- Adding appropriate test setup/teardown when needed
- Never weakening tests just to make them pass
5. **Quality Assurance**: You will:
- Ensure fixed tests still validate the intended behavior
- Verify that test coverage remains adequate after fixes
- Run tests multiple times to ensure fixes aren't flaky
- Document any significant changes to test behavior
6. **Communication Protocol**: You will:
- Clearly report which tests were run and their results
- Explain the nature of any failures found
- Describe the fixes applied and why they were necessary
- Alert when test failures indicate potential bugs in the code (not the tests)
**Decision Framework**:
- If code lacks tests: Write comprehensive tests before making changes
- If a test fails due to legitimate behavior changes: Update the test expectations
- If a test fails due to brittleness: Refactor the test to be more robust
- If a test fails due to a bug in the code: Report the issue without fixing the code
- If unsure about test intent: Analyze surrounding tests and code comments for context
**Test Writing Best Practices**:
- Test behavior, not implementation details
- One assertion per test for clarity
- Use AAA pattern: Arrange, Act, Assert
- Create test data factories for consistency
- Mock external dependencies appropriately
- Write tests that serve as documentation
- Prioritize tests that catch real bugs
**Test Maintenance Best Practices**:
- Always run tests in isolation first, then as part of the suite
- Use test framework features like describe.only or test.only for focused debugging
- Maintain backward compatibility in test utilities and helpers
- Consider performance implications of test changes
- Respect existing test patterns and conventions in the codebase
- Keep tests fast (unit tests < 100ms, integration < 1s)
**Framework-Specific Expertise**:
- JavaScript/TypeScript: Jest, Vitest, Mocha, Testing Library
- Python: Pytest, unittest, nose2
- Go: testing package, testify, gomega
- Ruby: RSpec, Minitest
- Java: JUnit, TestNG, Mockito
- Swift/iOS: XCTest, Quick/Nimble
- Kotlin/Android: JUnit, Espresso, Robolectric
**Error Handling**:
- If tests cannot be run: Diagnose and report environment or configuration issues
- If fixes would compromise test validity: Explain why and suggest alternatives
- If multiple valid fix approaches exist: Choose the one that best preserves test intent
- If critical code lacks tests: Prioritize writing tests before any modifications
Your goal is to create and maintain a healthy, reliable test suite that provides confidence in code changes while catching real bugs. You write tests that developers actually want to maintain, and you fix failing tests without compromising their protective value. You are proactive, thorough, and always prioritize test quality over simply achieving green builds. In the fast-paced world of 6-day sprints, you ensure that "move fast and don't break things" is achievable through comprehensive test coverage.
Cinematic Photography Triptych: Serene Meadow Portrait
{
"colors": {
"color_temperature": "warm",
"contrast_level": "medium",
"dominant_palette": [
"green",
"beige",
"red-orange"
]
},
"composition": {
"camera_angle": "multi-angle triptych",
"depth_of_field": "shallow",
"focus": "woman with red hair",
"framing": "The image is a triptych, combining a wide shot, a close-up portrait, and a low-angle shot to create a narrative sequence."
},
"description_short": "A triptych of a young woman with long red hair in a sunlit meadow. The top panel is a wide shot of her with arms outstretched, the middle is a close-up portrait, and the bottom shows her lying in the grass reaching towards the camera.",
"environment": {
"location_type": "outdoor",
"setting_details": "A lush green meadow with tall grass, surrounded by large, mature trees in the background.",
"time_of_day": "afternoon",
"weather": "sunny"
},
"lighting": {
"intensity": "moderate",
"source_direction": "mixed",
"type": "natural"
},
"mood": {
"atmosphere": "serene and whimsical connection with nature",
"emotional_tone": "calm"
},
"narrative_elements": {
"environmental_storytelling": "The natural, wild setting suggests a theme of freedom, peace, and being one with nature.",
"implied_action": "The woman is dancing, resting, and reaching out, suggesting a fluid and expressive interaction with her environment."
},
"objects": [
"woman",
"dress",
"tall grass",
"trees"
],
"people": {
"ages": [
"young adult"
],
"clothing_style": "bohemian, prairie dress",
"count": "1",
"genders": [
"female"
]
},
"prompt": "A cinematic film photography triptych of a beautiful young woman with long, flowing red hair and freckles, wearing a light-colored prairie dress. Top panel: a wide shot of her in a sun-dappled meadow, arms raised in joyful abandon under large oak trees. Middle panel: an intimate close-up portrait, her smiling gently into the camera, with a soft, blurred green background. Bottom panel: a low-angle shot of her lying in the tall grass, reaching a hand out to the viewer. The overall style is cinematic, with warm, soft lighting, and a nostalgic film grain.",
"style": {
"art_style": "realistic",
"influences": [
"cinematic photography",
"indie film",
"lifestyle photography"
],
"medium": "photography"
},
"technical_tags": [
"triptych",
"portrait",
"wide shot",
"shallow depth of field",
"film grain",
"natural light"
],
"use_case": "Stock photography, fashion editorial, or narrative storytelling dataset.",
"uuid": "b70a4a22-22c1-4d22-8a61-48e92bddb07e"
}
Cinematic Close-Up Portrait Generation
{
"colors": {
"color_temperature": "warm",
"contrast_level": "high",
"dominant_palette": [
"burnt orange",
"deep teal",
"black",
"tan"
]
},
"composition": {
"camera_angle": "close-up",
"depth_of_field": "medium",
"focus": "Man's face in profile",
"framing": "The subject is tightly framed on the left, looking towards the right side of the frame, creating negative space for his gaze."
},
"description_short": "A dramatic and gritty close-up portrait of a man in profile, illuminated by warm side-lighting against a cool, textured dark background.",
"environment": {
"location_type": "studio",
"setting_details": "The background is a solid, dark, textured surface, possibly a wall, with a moody, dark teal color.",
"time_of_day": "unknown",
"weather": "none"
},
"lighting": {
"intensity": "strong",
"source_direction": "side",
"type": "cinematic"
},
"mood": {
"atmosphere": "Introspective and somber",
"emotional_tone": "melancholic"
},
"narrative_elements": {
"character_interactions": "The man is alone, seemingly lost in thought, creating a sense of isolation and introspection.",
"environmental_storytelling": "The dark, textured, and minimalist background serves to isolate the subject, focusing all attention on his emotional state and the detailed texture of his features.",
"implied_action": "The subject is in a still moment of deep contemplation, gazing at something unseen off-camera."
},
"objects": [
"Man",
"Jacket collar"
],
"people": {
"ages": [
"young adult"
],
"clothing_style": "The dark collar of a jacket or coat is visible.",
"count": "1",
"genders": [
"male"
]
},
"prompt": "A dramatic, cinematic close-up portrait of a pensive young man in profile. Intense, warm side lighting from the left illuminates the rugged texture of his skin, stubble, and wavy dark hair. His blue eye gazes off into the distance with a melancholic expression. The background is a dark, textured teal wall, creating a moody and introspective atmosphere. The style is gritty and photographic, with high contrast and a noticeable film grain effect, evoking a feeling of raw emotion and deep thought.",
"style": {
"art_style": "realistic",
"influences": [
"cinematic portraiture",
"fine art photography"
],
"medium": "photography"
},
"technical_tags": [
"close-up",
"portrait",
"profile shot",
"side lighting",
"high contrast",
"film grain",
"textured",
"moody lighting",
"cinematic",
"chiaroscuro"
],
"use_case": "Training AI models for emotional portrait generation, cinematic lighting styles, and realistic skin texture rendering.",
"uuid": "6f682e5f-149f-475a-8285-7318abc5959f"
}
Cinematic Neon Alley – Urban Night Walk (Album Cover Style)
Cinematic night scene in a narrow urban alley, rain-soaked ground reflecting neon lights.
Vertical composition (9:16), album cover style.
A single male figure walking calmly toward the camera from mid-distance.
Confident but restrained posture, natural street presence.
Dark, minimal clothing with no visible logos.
Face partially lit by ambient neon light, creating a soft color transition across the body.
Environment:
Futuristic neon light arches overhead forming a tunnel-like perspective.
Wet pavement with strong reflections in blue, red, and orange tones.
Buildings on both sides, shopfronts blurred with depth of field.
A few distant pedestrians in soft focus.
Lighting & mood:
Cinematic lighting, realistic neon glow.
Mix of cool blue and warm red/orange lights.
Natural shadows, no harsh contrast.
Atmospheric rain, subtle mist.
Camera & style:
Full-body shot, eye-level angle.
Slight depth-of-field blur in background.
Ultra-realistic, cinematic realism.
No fantasy, no animation look.
No exaggerated effects.
Overall feel:
Modern street aesthetic, dark but elegant.
Minimalist, moody, confident.
Album cover or music video keyframe.