Skip to main content
ClaudeWave
Slash Command462 repo starsupdated 3d ago

validate-module

The validate-module command runs a two-agent validation system on a Python module and its tests to verify production-readiness. It uses a contract-extractor agent to analyze the module's public interface, return structures, and exception handling, then uses a test-validator agent to ensure tests comprehensively cover the extracted contracts. Use this when you need binary pass/fail validation with specific issues identified before deploying code to production.

Install in Claude Code
Copy
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/taylorsatula/mira-OSS/HEAD/.claude/commands/validate-module.md -o ~/.claude/commands/validate-module.md
Then start a new Claude Code session; the slash command loads automatically.

validate-module.md

# Module Validation Command

You are running the two-agent validation system to verify a module and its tests are production-ready.

## 🚨 CRITICAL: IMPLEMENTATION FILES ARE READ-ONLY

**YOU MUST NOT EDIT THE IMPLEMENTATION FILE BEING VALIDATED.**

During validation workflow:

**ALLOWED**:
- Read implementation file
- Edit TEST files to improve coverage/quality
- Add new tests
- Strengthen test assertions
- Fix test organization

**FORBIDDEN**:
- Edit implementation file
- Fix bugs in module code
- Refactor implementation
- Modify module behavior

**If validation reveals implementation bugs:**
1. Include in validation report
2. Present to user with note: "Implementation requires human review"
3. DO NOT fix implementation
4. Wait for user decision

**Validation tests the implementation AS-IS. User must decide on implementation changes.**

---

## Your Task

1. **Get module and test paths from user**
2. **Run contract-extractor agent** → Get contracts + validation checklist
3. **Run test-validator agent** → Get verdict (VALIDATED or BLOCKED)
4. **Report results clearly** → Present verdict + issues
5. **If implementation issues found** → Report to user, await decision

## Protocol

### Step 1: Get Paths

Ask user for:
- **Module path**: The Python module to validate
- **Test path**: The test file (or auto-detect from module path)

Auto-detect test path:
```
Module: tools/implementations/reminder_tool.py
→ Test: tests/tools/implementations/test_reminder_tool.py
```

### Step 2: Extract Contracts

Invoke contract-extractor agent:

```
Use Task tool:
subagent_type="contract-extractor"
description="Extract module contracts"
prompt="""Extract complete contract from module: [module_path]

Provide:
- Public interface (methods, signatures, types)
- Actual return structures (exact dict keys, types, constraints)
- Exception contracts (what raises what, when)
- Edge cases handled
- Dependencies and architectural concerns
- VALIDATION CHECKLIST with numbered requirements (R1, E1, EC1, S1, A1)

Module path: [module_path]"""
```

Wait for agent to complete. You will receive contract report with validation checklist.

### Step 3: Validate Tests

Invoke test-validator agent with contracts + test file:

```
Use Task tool:
subagent_type="test-validator"
description="Validate tests against contracts"
prompt="""Validate tests against extracted contracts:

MODULE: [module_path]
TESTS: [test_path]

CONTRACT REPORT:
[paste full contract report from Step 2]

Verify:
1. Contract Coverage - do tests cover all requirements from validation checklist?
2. Test Quality - are assertions strong? negative tests present?
3. Architecture - are design concerns acceptable?

Provide binary verdict: ✓ VALIDATED or ✗ BLOCKED
If blocked, list specific issues with file paths and line numbers."""
```

Wait for agent to complete. You will receive validation report with verdict.

### Step 4: Report Results

Present results to user in clear format:

**If ✓ VALIDATED:**
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ MODULE VALIDATED
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Module: [module_path]
Tests: [test_path]

VALIDATION PASSED
─────────────────────────────────────────────────────

✓ Contract Coverage: [X%] (>= 95% required)
✓ Test Quality: [STRONG/GOOD]
✓ Architecture: [PASS/CONCERNS]

SUMMARY:
- All contracts tested
- Test quality verified
- Architecture sound
- Module is production-ready

[If any warnings exist, list them]
```

**If ✗ BLOCKED:**
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
❌ VALIDATION BLOCKED
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Module: [module_path]
Tests: [test_path]

BLOCKING ISSUES ([count] issues must be fixed)
─────────────────────────────────────────────────────

[List each blocking issue from validation report]

Example:
1. R5 NOT COVERED: Missing test for result structure fields
   → Add test verifying each result has: message_id, content, match_score
   → File: tests/tools/implementations/test_conversationsearch_tool.py

2. E3 NOT COVERED: Missing test for ValueError on invalid message_id
   → Add test: test_expand_rejects_invalid_message_id()
   → File: tests/tools/implementations/test_conversationsearch_tool.py

VALIDATION SUMMARY:
─────────────────────────────────────────────────────
Contract Coverage: [X%] (95% required)
Test Quality: [rating]
Architecture: [status]

ACTION REQUIRED:
Fix the [count] blocking issues above and re-run validation.
```

### Step 5: Offer Re-validation

Ask user if they want to:
- Fix issues now and re-validate
- Review issues and validate later
- See full validation report details

## Mode Detection

**GUIDE MODE** (if tests don't exist):
```
User provides module path, but test file doesn't exist.

Response:
"No test file found at: [test_path]

Would you like to:
1. Use GUIDE MODE - I'll extract contracts and help you write tests
2. Specify a different test file path
3. Cancel validation"

If user chooses GUIDE MODE:
1. Extract contracts
2. Present validation checklist
3. Guide test writing
4. Offer to validate once tests written
```

**VALIDATION MODE** (if both exist):
```
Both module and tests exist → proceed with full validation
```

## Example Usage

## Complete Workflow

1. Ask user for module path (or use provided path)
2. Auto-detect test path: `tools/foo.py` → `tests/tools/test_foo.py`
3. Check if test file exists - if not, offer GUIDE MODE
4. Invoke contract-extractor with full prompt from Step 2
5. Invoke test-validator with full prompt from Step 3 + contract report
6. Parse validation report for verdict
7. Present results using format from Step 4

**For report formats, see**:
- contract-extractor.md for contract extraction format
- test-validator.md for validation report format

**Done**: Present clear verdict to user with actionable issues if blocked.
code-renamerSubagent

Use this agent when you need to rename classes, methods, functions, or variables in code files to align with specific naming requirements or conventions. Examples: <example>Context: User wants to clean up function names by removing a specific prefix. user: 'Please remove the prefix get_ from all function names in this file' assistant: 'I'll use the code-renamer agent to systematically rename all functions by removing the get_ prefix' <commentary>The user wants systematic renaming of functions, which is exactly what the code-renamer agent is designed for.</commentary></example> <example>Context: User wants to standardize method naming conventions. user: 'Can you rename all the camelCase methods to snake_case in this class?' assistant: 'I'll use the code-renamer agent to convert all camelCase method names to snake_case convention' <commentary>This is a systematic renaming task that requires careful attention to naming conventions.</commentary></example>

investigative-sidekickSubagent

Use this agent when the user makes offhanded comments, rhetorical questions, or expresses wishes about understanding something better. Trigger on patterns like:\n\n<example>\nContext: User is reviewing code and sees an assistant's explanation about how a function works.\nuser: "Can you believe this? Is this even right?"\nassistant: "Let me use the investigative-sidekick agent to verify if that explanation is accurate."\n<task tool_call to investigative-sidekick with context about what needs verification>\n</example>\n\n<example>\nContext: User is debugging and expresses frustration.\nuser: "I wish I could figure out what's causing this memory leak in the session handler"\nassistant: "I'll use the investigative-sidekick agent to investigate the root cause of that memory leak."\n<task tool_call to investigative-sidekick with the specific problem to investigate>\n</example>\n\n<example>\nContext: User reads a commit message claiming a performance improvement.\nuser: "Did this actually make things faster though?"\nassistant: "Let me launch the investigative-sidekick agent to verify that performance claim."\n<task tool_call to investigative-sidekick to fact-check the performance assertion>\n</example>\n\n<example>\nContext: User is reviewing documentation that seems questionable.\nuser: "This doesn't seem right - are we really supposed to use sync calls in async contexts?"\nassistant: "I'm going to use the investigative-sidekick agent to investigate whether that's actually correct."\n<task tool_call to investigative-sidekick to verify the technical claim>\n</example>\n\nActivate proactively when the user:\n- Questions accuracy or truthfulness ("Can you believe...", "Is this right?", "Really?")\n- Expresses wishes about understanding ("I wish I could figure out...", "I'd love to know...")\n- Shows skepticism ("Did this actually...", "Does this really...")\n- Makes rhetorical questions that imply investigation ("What's causing...", "Why is this...")\n- Doubts explanations or documentation they're reading

thinkSlash Command

Control thinking token limits via environment variable

Code Consistency - Logging & StandardsSkill

Check Python logging levels and patterns for correctness. Focus on identifying wrong severity levels and missing exception handling. Use when reviewing code quality.

contextvar-opportunity-finderSkill

Detect explicit user_id parameters in functions to identify potential opportunities for using ambient context. This is an investigation tool that flags instances for human review, not a prescriptive analyzer.

contextvar-remediationSkill
fail-fast-no-hedgingSkill

Eliminate component hedging anti-patterns that mask infrastructure failures. Build systems that fail loudly when broken instead of limping along in degraded states. Critical for production reliability and operational visibility.

Git WorkflowSkill

DO NOT COMMIT unless user explicitly tells you to. Use this skill EVERY SINGLE TIME before creating a git commit. Provides mandatory commit message format, staging rules, and post-commit summary requirements for the MIRA project