claude-mpm 4.14.6__py3-none-any.whl → 4.21.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- claude_mpm/VERSION +1 -1
- claude_mpm/agents/BASE_ENGINEER.md +286 -0
- claude_mpm/agents/BASE_PM.md +272 -23
- claude_mpm/agents/OUTPUT_STYLE.md +48 -3
- claude_mpm/agents/PM_INSTRUCTIONS.md +49 -0
- claude_mpm/agents/agent_loader.py +17 -5
- claude_mpm/agents/frontmatter_validator.py +284 -253
- claude_mpm/agents/templates/agentic-coder-optimizer.json +9 -2
- claude_mpm/agents/templates/api_qa.json +7 -1
- claude_mpm/agents/templates/clerk-ops.json +8 -1
- claude_mpm/agents/templates/code_analyzer.json +4 -1
- claude_mpm/agents/templates/dart_engineer.json +11 -1
- claude_mpm/agents/templates/data_engineer.json +11 -1
- claude_mpm/agents/templates/documentation.json +6 -1
- claude_mpm/agents/templates/engineer.json +18 -1
- claude_mpm/agents/templates/gcp_ops_agent.json +8 -1
- claude_mpm/agents/templates/golang_engineer.json +11 -1
- claude_mpm/agents/templates/java_engineer.json +12 -2
- claude_mpm/agents/templates/local_ops_agent.json +216 -37
- claude_mpm/agents/templates/nextjs_engineer.json +11 -1
- claude_mpm/agents/templates/ops.json +8 -1
- claude_mpm/agents/templates/php-engineer.json +20 -4
- claude_mpm/agents/templates/project_organizer.json +10 -3
- claude_mpm/agents/templates/prompt-engineer.json +5 -1
- claude_mpm/agents/templates/python_engineer.json +19 -4
- claude_mpm/agents/templates/qa.json +7 -1
- claude_mpm/agents/templates/react_engineer.json +11 -1
- claude_mpm/agents/templates/refactoring_engineer.json +8 -1
- claude_mpm/agents/templates/research.json +4 -1
- claude_mpm/agents/templates/ruby-engineer.json +11 -1
- claude_mpm/agents/templates/rust_engineer.json +23 -8
- claude_mpm/agents/templates/security.json +6 -1
- claude_mpm/agents/templates/svelte-engineer.json +225 -0
- claude_mpm/agents/templates/ticketing.json +6 -1
- claude_mpm/agents/templates/typescript_engineer.json +11 -1
- claude_mpm/agents/templates/vercel_ops_agent.json +8 -1
- claude_mpm/agents/templates/version_control.json +8 -1
- claude_mpm/agents/templates/web_qa.json +7 -1
- claude_mpm/agents/templates/web_ui.json +11 -1
- claude_mpm/cli/__init__.py +34 -740
- claude_mpm/cli/commands/__init__.py +2 -0
- claude_mpm/cli/commands/agent_manager.py +25 -12
- claude_mpm/cli/commands/agent_state_manager.py +186 -0
- claude_mpm/cli/commands/agents.py +204 -148
- claude_mpm/cli/commands/aggregate.py +7 -3
- claude_mpm/cli/commands/analyze.py +9 -4
- claude_mpm/cli/commands/analyze_code.py +7 -2
- claude_mpm/cli/commands/auto_configure.py +7 -9
- claude_mpm/cli/commands/config.py +47 -13
- claude_mpm/cli/commands/configure.py +294 -1788
- claude_mpm/cli/commands/configure_agent_display.py +261 -0
- claude_mpm/cli/commands/configure_behavior_manager.py +204 -0
- claude_mpm/cli/commands/configure_hook_manager.py +225 -0
- claude_mpm/cli/commands/configure_models.py +18 -0
- claude_mpm/cli/commands/configure_navigation.py +167 -0
- claude_mpm/cli/commands/configure_paths.py +104 -0
- claude_mpm/cli/commands/configure_persistence.py +254 -0
- claude_mpm/cli/commands/configure_startup_manager.py +646 -0
- claude_mpm/cli/commands/configure_template_editor.py +497 -0
- claude_mpm/cli/commands/configure_validators.py +73 -0
- claude_mpm/cli/commands/local_deploy.py +3 -2
- claude_mpm/cli/commands/memory.py +54 -20
- claude_mpm/cli/commands/mpm_init/__init__.py +73 -0
- claude_mpm/cli/commands/mpm_init/core.py +525 -0
- claude_mpm/cli/commands/mpm_init/display.py +341 -0
- claude_mpm/cli/commands/mpm_init/git_activity.py +427 -0
- claude_mpm/cli/commands/mpm_init/modes.py +397 -0
- claude_mpm/cli/commands/mpm_init/prompts.py +442 -0
- claude_mpm/cli/commands/mpm_init_cli.py +396 -0
- claude_mpm/cli/commands/mpm_init_handler.py +75 -4
- claude_mpm/cli/commands/skills.py +488 -0
- claude_mpm/cli/executor.py +204 -0
- claude_mpm/cli/helpers.py +105 -0
- claude_mpm/cli/interactive/__init__.py +3 -0
- claude_mpm/cli/interactive/skills_wizard.py +491 -0
- claude_mpm/cli/parsers/base_parser.py +7 -0
- claude_mpm/cli/parsers/mpm_init_parser.py +42 -0
- claude_mpm/cli/parsers/skills_parser.py +137 -0
- claude_mpm/cli/shared/output_formatters.py +28 -19
- claude_mpm/cli/startup.py +538 -0
- claude_mpm/commands/mpm-auto-configure.md +52 -0
- claude_mpm/commands/mpm-help.md +3 -0
- claude_mpm/commands/mpm-init.md +112 -6
- claude_mpm/commands/mpm-version.md +113 -0
- claude_mpm/commands/mpm.md +1 -0
- claude_mpm/config/agent_config.py +2 -2
- claude_mpm/constants.py +12 -0
- claude_mpm/core/base_service.py +13 -12
- claude_mpm/core/config.py +42 -0
- claude_mpm/core/enums.py +452 -0
- claude_mpm/core/factories.py +1 -1
- claude_mpm/core/instruction_reinforcement_hook.py +2 -1
- claude_mpm/core/interactive_session.py +6 -3
- claude_mpm/core/interfaces.py +56 -1
- claude_mpm/core/logging_config.py +6 -2
- claude_mpm/core/oneshot_session.py +8 -4
- claude_mpm/core/optimized_agent_loader.py +3 -3
- claude_mpm/core/output_style_manager.py +12 -192
- claude_mpm/core/service_registry.py +5 -1
- claude_mpm/core/types.py +2 -9
- claude_mpm/core/typing_utils.py +7 -6
- claude_mpm/dashboard/static/js/dashboard.js +0 -14
- claude_mpm/dashboard/templates/index.html +3 -41
- claude_mpm/hooks/__init__.py +8 -0
- claude_mpm/hooks/claude_hooks/response_tracking.py +35 -1
- claude_mpm/hooks/instruction_reinforcement.py +7 -2
- claude_mpm/hooks/session_resume_hook.py +121 -0
- claude_mpm/models/resume_log.py +340 -0
- claude_mpm/services/agents/auto_config_manager.py +10 -11
- claude_mpm/services/agents/deployment/agent_configuration_manager.py +1 -1
- claude_mpm/services/agents/deployment/agent_record_service.py +1 -1
- claude_mpm/services/agents/deployment/agent_validator.py +17 -1
- claude_mpm/services/agents/deployment/async_agent_deployment.py +1 -1
- claude_mpm/services/agents/deployment/interface_adapter.py +3 -2
- claude_mpm/services/agents/deployment/local_template_deployment.py +1 -1
- claude_mpm/services/agents/deployment/pipeline/steps/agent_processing_step.py +7 -6
- claude_mpm/services/agents/deployment/pipeline/steps/base_step.py +7 -16
- claude_mpm/services/agents/deployment/pipeline/steps/configuration_step.py +4 -3
- claude_mpm/services/agents/deployment/pipeline/steps/target_directory_step.py +5 -3
- claude_mpm/services/agents/deployment/pipeline/steps/validation_step.py +6 -5
- claude_mpm/services/agents/deployment/refactored_agent_deployment_service.py +9 -6
- claude_mpm/services/agents/deployment/validation/__init__.py +3 -1
- claude_mpm/services/agents/deployment/validation/validation_result.py +1 -9
- claude_mpm/services/agents/local_template_manager.py +1 -1
- claude_mpm/services/agents/memory/agent_memory_manager.py +5 -2
- claude_mpm/services/agents/recommender.py +47 -0
- claude_mpm/services/agents/registry/modification_tracker.py +5 -2
- claude_mpm/services/cli/resume_service.py +617 -0
- claude_mpm/services/cli/session_manager.py +87 -0
- claude_mpm/services/cli/session_pause_manager.py +504 -0
- claude_mpm/services/cli/session_resume_helper.py +372 -0
- claude_mpm/services/command_handler_service.py +11 -5
- claude_mpm/services/core/interfaces/process.py +6 -6
- claude_mpm/services/core/interfaces.py +56 -1
- claude_mpm/services/core/models/__init__.py +0 -2
- claude_mpm/services/core/models/agent_config.py +15 -28
- claude_mpm/services/core/models/health.py +1 -28
- claude_mpm/services/core/models/process.py +22 -41
- claude_mpm/services/core/path_resolver.py +1 -1
- claude_mpm/services/diagnostics/__init__.py +2 -2
- claude_mpm/services/diagnostics/checks/agent_check.py +25 -24
- claude_mpm/services/diagnostics/checks/claude_code_check.py +24 -23
- claude_mpm/services/diagnostics/checks/common_issues_check.py +25 -24
- claude_mpm/services/diagnostics/checks/configuration_check.py +24 -23
- claude_mpm/services/diagnostics/checks/filesystem_check.py +18 -17
- claude_mpm/services/diagnostics/checks/installation_check.py +30 -29
- claude_mpm/services/diagnostics/checks/instructions_check.py +20 -19
- claude_mpm/services/diagnostics/checks/mcp_check.py +50 -36
- claude_mpm/services/diagnostics/checks/mcp_services_check.py +36 -31
- claude_mpm/services/diagnostics/checks/monitor_check.py +23 -22
- claude_mpm/services/diagnostics/checks/startup_log_check.py +9 -8
- claude_mpm/services/diagnostics/diagnostic_runner.py +6 -5
- claude_mpm/services/diagnostics/doctor_reporter.py +28 -25
- claude_mpm/services/diagnostics/models.py +37 -21
- claude_mpm/services/infrastructure/monitoring/__init__.py +1 -1
- claude_mpm/services/infrastructure/monitoring/aggregator.py +12 -12
- claude_mpm/services/infrastructure/monitoring/base.py +5 -13
- claude_mpm/services/infrastructure/monitoring/network.py +7 -6
- claude_mpm/services/infrastructure/monitoring/process.py +13 -12
- claude_mpm/services/infrastructure/monitoring/resources.py +7 -6
- claude_mpm/services/infrastructure/monitoring/service.py +16 -15
- claude_mpm/services/infrastructure/resume_log_generator.py +439 -0
- claude_mpm/services/local_ops/__init__.py +5 -3
- claude_mpm/services/local_ops/crash_detector.py +1 -1
- claude_mpm/services/local_ops/health_checks/http_check.py +2 -1
- claude_mpm/services/local_ops/health_checks/process_check.py +2 -1
- claude_mpm/services/local_ops/health_checks/resource_check.py +2 -1
- claude_mpm/services/local_ops/health_manager.py +1 -1
- claude_mpm/services/local_ops/process_manager.py +12 -12
- claude_mpm/services/local_ops/restart_manager.py +1 -1
- claude_mpm/services/local_ops/state_manager.py +6 -5
- claude_mpm/services/local_ops/unified_manager.py +2 -2
- claude_mpm/services/mcp_config_manager.py +7 -126
- claude_mpm/services/mcp_gateway/auto_configure.py +31 -25
- claude_mpm/services/mcp_gateway/core/__init__.py +1 -2
- claude_mpm/services/mcp_gateway/core/base.py +18 -31
- claude_mpm/services/mcp_gateway/core/process_pool.py +19 -10
- claude_mpm/services/mcp_gateway/tools/external_mcp_services.py +97 -45
- claude_mpm/services/mcp_gateway/tools/health_check_tool.py +30 -28
- claude_mpm/services/memory_hook_service.py +4 -1
- claude_mpm/services/monitor/daemon_manager.py +3 -2
- claude_mpm/services/monitor/handlers/dashboard.py +2 -1
- claude_mpm/services/monitor/handlers/hooks.py +2 -1
- claude_mpm/services/monitor/management/lifecycle.py +3 -2
- claude_mpm/services/monitor/server.py +2 -1
- claude_mpm/services/session_management_service.py +3 -2
- claude_mpm/services/session_manager.py +205 -1
- claude_mpm/services/shared/async_service_base.py +16 -27
- claude_mpm/services/shared/lifecycle_service_base.py +1 -14
- claude_mpm/services/socketio/handlers/__init__.py +5 -2
- claude_mpm/services/socketio/handlers/hook.py +13 -2
- claude_mpm/services/socketio/handlers/registry.py +4 -2
- claude_mpm/services/socketio/server/main.py +10 -8
- claude_mpm/services/subprocess_launcher_service.py +14 -5
- claude_mpm/services/unified/analyzer_strategies/code_analyzer.py +8 -7
- claude_mpm/services/unified/analyzer_strategies/dependency_analyzer.py +6 -5
- claude_mpm/services/unified/analyzer_strategies/performance_analyzer.py +8 -7
- claude_mpm/services/unified/analyzer_strategies/security_analyzer.py +7 -6
- claude_mpm/services/unified/analyzer_strategies/structure_analyzer.py +5 -4
- claude_mpm/services/unified/config_strategies/validation_strategy.py +13 -9
- claude_mpm/services/unified/deployment_strategies/cloud_strategies.py +10 -3
- claude_mpm/services/unified/deployment_strategies/local.py +6 -5
- claude_mpm/services/unified/deployment_strategies/utils.py +6 -5
- claude_mpm/services/unified/deployment_strategies/vercel.py +7 -6
- claude_mpm/services/unified/interfaces.py +3 -1
- claude_mpm/services/unified/unified_analyzer.py +14 -10
- claude_mpm/services/unified/unified_config.py +2 -1
- claude_mpm/services/unified/unified_deployment.py +9 -4
- claude_mpm/services/version_service.py +104 -1
- claude_mpm/skills/__init__.py +42 -0
- claude_mpm/skills/agent_skills_injector.py +324 -0
- claude_mpm/skills/bundled/LICENSE_ATTRIBUTIONS.md +79 -0
- claude_mpm/skills/bundled/__init__.py +6 -0
- claude_mpm/skills/bundled/api-documentation.md +393 -0
- claude_mpm/skills/bundled/async-testing.md +571 -0
- claude_mpm/skills/bundled/code-review.md +143 -0
- claude_mpm/skills/bundled/collaboration/brainstorming/SKILL.md +79 -0
- claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/SKILL.md +178 -0
- claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/agent-prompts.md +577 -0
- claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/coordination-patterns.md +467 -0
- claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/examples.md +537 -0
- claude_mpm/skills/bundled/collaboration/dispatching-parallel-agents/references/troubleshooting.md +730 -0
- claude_mpm/skills/bundled/collaboration/requesting-code-review/SKILL.md +112 -0
- claude_mpm/skills/bundled/collaboration/requesting-code-review/references/code-reviewer-template.md +146 -0
- claude_mpm/skills/bundled/collaboration/requesting-code-review/references/review-examples.md +412 -0
- claude_mpm/skills/bundled/collaboration/writing-plans/SKILL.md +81 -0
- claude_mpm/skills/bundled/collaboration/writing-plans/references/best-practices.md +362 -0
- claude_mpm/skills/bundled/collaboration/writing-plans/references/plan-structure-templates.md +312 -0
- claude_mpm/skills/bundled/database-migration.md +199 -0
- claude_mpm/skills/bundled/debugging/root-cause-tracing/SKILL.md +152 -0
- claude_mpm/skills/bundled/debugging/root-cause-tracing/references/advanced-techniques.md +668 -0
- claude_mpm/skills/bundled/debugging/root-cause-tracing/references/examples.md +587 -0
- claude_mpm/skills/bundled/debugging/root-cause-tracing/references/integration.md +438 -0
- claude_mpm/skills/bundled/debugging/root-cause-tracing/references/tracing-techniques.md +391 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/CREATION-LOG.md +119 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/SKILL.md +148 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/references/anti-patterns.md +483 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/references/examples.md +452 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/references/troubleshooting.md +449 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/references/workflow.md +411 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/test-academic.md +14 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/test-pressure-1.md +58 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/test-pressure-2.md +68 -0
- claude_mpm/skills/bundled/debugging/systematic-debugging/test-pressure-3.md +69 -0
- claude_mpm/skills/bundled/debugging/verification-before-completion/SKILL.md +131 -0
- claude_mpm/skills/bundled/debugging/verification-before-completion/references/gate-function.md +325 -0
- claude_mpm/skills/bundled/debugging/verification-before-completion/references/integration-and-workflows.md +490 -0
- claude_mpm/skills/bundled/debugging/verification-before-completion/references/red-flags-and-failures.md +425 -0
- claude_mpm/skills/bundled/debugging/verification-before-completion/references/verification-patterns.md +499 -0
- claude_mpm/skills/bundled/docker-containerization.md +194 -0
- claude_mpm/skills/bundled/express-local-dev.md +1429 -0
- claude_mpm/skills/bundled/fastapi-local-dev.md +1199 -0
- claude_mpm/skills/bundled/git-workflow.md +414 -0
- claude_mpm/skills/bundled/imagemagick.md +204 -0
- claude_mpm/skills/bundled/json-data-handling.md +223 -0
- claude_mpm/skills/bundled/main/artifacts-builder/SKILL.md +86 -0
- claude_mpm/skills/bundled/main/internal-comms/SKILL.md +43 -0
- claude_mpm/skills/bundled/main/internal-comms/examples/3p-updates.md +47 -0
- claude_mpm/skills/bundled/main/internal-comms/examples/company-newsletter.md +65 -0
- claude_mpm/skills/bundled/main/internal-comms/examples/faq-answers.md +30 -0
- claude_mpm/skills/bundled/main/internal-comms/examples/general-comms.md +16 -0
- claude_mpm/skills/bundled/main/mcp-builder/SKILL.md +160 -0
- claude_mpm/skills/bundled/main/mcp-builder/reference/design_principles.md +412 -0
- claude_mpm/skills/bundled/main/mcp-builder/reference/evaluation.md +602 -0
- claude_mpm/skills/bundled/main/mcp-builder/reference/mcp_best_practices.md +915 -0
- claude_mpm/skills/bundled/main/mcp-builder/reference/node_mcp_server.md +916 -0
- claude_mpm/skills/bundled/main/mcp-builder/reference/python_mcp_server.md +752 -0
- claude_mpm/skills/bundled/main/mcp-builder/reference/workflow.md +1237 -0
- claude_mpm/skills/bundled/main/mcp-builder/scripts/connections.py +157 -0
- claude_mpm/skills/bundled/main/mcp-builder/scripts/evaluation.py +425 -0
- claude_mpm/skills/bundled/main/skill-creator/SKILL.md +189 -0
- claude_mpm/skills/bundled/main/skill-creator/references/best-practices.md +500 -0
- claude_mpm/skills/bundled/main/skill-creator/references/creation-workflow.md +464 -0
- claude_mpm/skills/bundled/main/skill-creator/references/examples.md +619 -0
- claude_mpm/skills/bundled/main/skill-creator/references/progressive-disclosure.md +437 -0
- claude_mpm/skills/bundled/main/skill-creator/references/skill-structure.md +231 -0
- claude_mpm/skills/bundled/main/skill-creator/scripts/init_skill.py +303 -0
- claude_mpm/skills/bundled/main/skill-creator/scripts/package_skill.py +113 -0
- claude_mpm/skills/bundled/main/skill-creator/scripts/quick_validate.py +72 -0
- claude_mpm/skills/bundled/nextjs-local-dev.md +807 -0
- claude_mpm/skills/bundled/pdf.md +141 -0
- claude_mpm/skills/bundled/performance-profiling.md +567 -0
- claude_mpm/skills/bundled/php/espocrm-development/SKILL.md +170 -0
- claude_mpm/skills/bundled/php/espocrm-development/references/architecture.md +602 -0
- claude_mpm/skills/bundled/php/espocrm-development/references/common-tasks.md +821 -0
- claude_mpm/skills/bundled/php/espocrm-development/references/development-workflow.md +742 -0
- claude_mpm/skills/bundled/php/espocrm-development/references/frontend-customization.md +726 -0
- claude_mpm/skills/bundled/php/espocrm-development/references/hooks-and-services.md +764 -0
- claude_mpm/skills/bundled/php/espocrm-development/references/testing-debugging.md +831 -0
- claude_mpm/skills/bundled/refactoring-patterns.md +180 -0
- claude_mpm/skills/bundled/rust/desktop-applications/SKILL.md +226 -0
- claude_mpm/skills/bundled/rust/desktop-applications/references/architecture-patterns.md +901 -0
- claude_mpm/skills/bundled/rust/desktop-applications/references/native-gui-frameworks.md +901 -0
- claude_mpm/skills/bundled/rust/desktop-applications/references/platform-integration.md +775 -0
- claude_mpm/skills/bundled/rust/desktop-applications/references/state-management.md +937 -0
- claude_mpm/skills/bundled/rust/desktop-applications/references/tauri-framework.md +770 -0
- claude_mpm/skills/bundled/rust/desktop-applications/references/testing-deployment.md +961 -0
- claude_mpm/skills/bundled/security-scanning.md +327 -0
- claude_mpm/skills/bundled/systematic-debugging.md +473 -0
- claude_mpm/skills/bundled/test-driven-development.md +378 -0
- claude_mpm/skills/bundled/testing/condition-based-waiting/SKILL.md +119 -0
- claude_mpm/skills/bundled/testing/condition-based-waiting/references/patterns-and-implementation.md +253 -0
- claude_mpm/skills/bundled/testing/test-driven-development/SKILL.md +145 -0
- claude_mpm/skills/bundled/testing/test-driven-development/references/anti-patterns.md +543 -0
- claude_mpm/skills/bundled/testing/test-driven-development/references/examples.md +741 -0
- claude_mpm/skills/bundled/testing/test-driven-development/references/integration.md +470 -0
- claude_mpm/skills/bundled/testing/test-driven-development/references/philosophy.md +458 -0
- claude_mpm/skills/bundled/testing/test-driven-development/references/workflow.md +639 -0
- claude_mpm/skills/bundled/testing/testing-anti-patterns/SKILL.md +140 -0
- claude_mpm/skills/bundled/testing/testing-anti-patterns/references/completeness-anti-patterns.md +572 -0
- claude_mpm/skills/bundled/testing/testing-anti-patterns/references/core-anti-patterns.md +411 -0
- claude_mpm/skills/bundled/testing/testing-anti-patterns/references/detection-guide.md +569 -0
- claude_mpm/skills/bundled/testing/testing-anti-patterns/references/tdd-connection.md +695 -0
- claude_mpm/skills/bundled/testing/webapp-testing/SKILL.md +184 -0
- claude_mpm/skills/bundled/testing/webapp-testing/decision-tree.md +459 -0
- claude_mpm/skills/bundled/testing/webapp-testing/examples/console_logging.py +35 -0
- claude_mpm/skills/bundled/testing/webapp-testing/examples/element_discovery.py +44 -0
- claude_mpm/skills/bundled/testing/webapp-testing/examples/static_html_automation.py +34 -0
- claude_mpm/skills/bundled/testing/webapp-testing/playwright-patterns.md +479 -0
- claude_mpm/skills/bundled/testing/webapp-testing/reconnaissance-pattern.md +687 -0
- claude_mpm/skills/bundled/testing/webapp-testing/scripts/with_server.py +129 -0
- claude_mpm/skills/bundled/testing/webapp-testing/server-management.md +758 -0
- claude_mpm/skills/bundled/testing/webapp-testing/troubleshooting.md +868 -0
- claude_mpm/skills/bundled/vite-local-dev.md +1061 -0
- claude_mpm/skills/bundled/web-performance-optimization.md +2305 -0
- claude_mpm/skills/bundled/xlsx.md +157 -0
- claude_mpm/skills/registry.py +286 -0
- claude_mpm/skills/skill_manager.py +310 -0
- claude_mpm/skills/skills_registry.py +348 -0
- claude_mpm/skills/skills_service.py +739 -0
- claude_mpm/tools/code_tree_analyzer.py +177 -141
- claude_mpm/tools/code_tree_events.py +4 -2
- claude_mpm/utils/agent_dependency_loader.py +2 -2
- {claude_mpm-4.14.6.dist-info → claude_mpm-4.21.0.dist-info}/METADATA +211 -33
- {claude_mpm-4.14.6.dist-info → claude_mpm-4.21.0.dist-info}/RECORD +339 -199
- claude_mpm/agents/INSTRUCTIONS_OLD_DEPRECATED.md +0 -602
- claude_mpm/cli/commands/mpm_init.py +0 -1994
- claude_mpm/dashboard/static/css/code-tree.css +0 -1639
- claude_mpm/dashboard/static/js/components/code-tree/tree-breadcrumb.js +0 -353
- claude_mpm/dashboard/static/js/components/code-tree/tree-constants.js +0 -235
- claude_mpm/dashboard/static/js/components/code-tree/tree-search.js +0 -409
- claude_mpm/dashboard/static/js/components/code-tree/tree-utils.js +0 -435
- claude_mpm/dashboard/static/js/components/code-tree.js +0 -5869
- claude_mpm/dashboard/static/js/components/code-viewer.js +0 -1386
- claude_mpm/hooks/claude_hooks/hook_handler_eventbus.py +0 -425
- claude_mpm/hooks/claude_hooks/hook_handler_original.py +0 -1041
- claude_mpm/hooks/claude_hooks/hook_handler_refactored.py +0 -347
- claude_mpm/services/agents/deployment/agent_lifecycle_manager_refactored.py +0 -575
- claude_mpm/services/project/analyzer_refactored.py +0 -450
- {claude_mpm-4.14.6.dist-info → claude_mpm-4.21.0.dist-info}/WHEEL +0 -0
- {claude_mpm-4.14.6.dist-info → claude_mpm-4.21.0.dist-info}/entry_points.txt +0 -0
- {claude_mpm-4.14.6.dist-info → claude_mpm-4.21.0.dist-info}/licenses/LICENSE +0 -0
- {claude_mpm-4.14.6.dist-info → claude_mpm-4.21.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Testing Anti-Patterns
|
|
3
|
+
description: Never test mock behavior. Never add test-only methods to production classes. Understand dependencies before mocking.
|
|
4
|
+
when_to_use: when writing or changing tests, adding mocks, or tempted to add test-only methods to production code
|
|
5
|
+
version: 2.0.0
|
|
6
|
+
progressive_disclosure:
|
|
7
|
+
entry_point:
|
|
8
|
+
summary: "Avoid testing mocks, test-only production methods, and incomplete mocking. Test real behavior, not mock behavior."
|
|
9
|
+
when_to_use: "When writing tests, adding mocks, reviewing test failures, or tempted to add test-only methods to production code."
|
|
10
|
+
quick_start: "1. Ask: 'Am I testing real behavior?' 2. Check: 'Is this method only for tests?' 3. Verify: 'Do I understand what I'm mocking?' 4. Confirm: 'Is my mock complete?' 5. Apply: TDD prevents these patterns"
|
|
11
|
+
references:
|
|
12
|
+
- core-anti-patterns.md
|
|
13
|
+
- completeness-anti-patterns.md
|
|
14
|
+
- detection-guide.md
|
|
15
|
+
- tdd-connection.md
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Testing Anti-Patterns
|
|
19
|
+
|
|
20
|
+
## Overview
|
|
21
|
+
|
|
22
|
+
Tests must verify real behavior, not mock behavior. Mocks are a means to isolate, not the thing being tested.
|
|
23
|
+
|
|
24
|
+
**Core principle:** Test what the code does, not what the mocks do.
|
|
25
|
+
|
|
26
|
+
**Following strict TDD prevents these anti-patterns.** See [test-driven-development skill](../test-driven-development/) for the complete TDD workflow.
|
|
27
|
+
|
|
28
|
+
## When to Use This Skill
|
|
29
|
+
|
|
30
|
+
Activate this skill when you're:
|
|
31
|
+
- **Writing or changing tests** - Verify you're testing real behavior
|
|
32
|
+
- **Adding mocks** - Ensure mocking is necessary and correct
|
|
33
|
+
- **Reviewing test failures** - Check if mock behavior is the issue
|
|
34
|
+
- **Tempted to add test-only methods** - STOP and reconsider
|
|
35
|
+
- **Tests feel overly complex** - Sign of over-mocking
|
|
36
|
+
|
|
37
|
+
## The Iron Laws
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
1. NEVER test mock behavior
|
|
41
|
+
2. NEVER add test-only methods to production classes
|
|
42
|
+
3. NEVER mock without understanding dependencies
|
|
43
|
+
4. NEVER create incomplete mocks
|
|
44
|
+
5. NEVER treat tests as afterthought
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Core Anti-Pattern Categories
|
|
48
|
+
|
|
49
|
+
### 1. Testing Mock Behavior
|
|
50
|
+
Asserting on mock elements instead of real behavior. **Fix:** Test real component or don't mock it.
|
|
51
|
+
**→** [core-anti-patterns.md](references/core-anti-patterns.md#anti-pattern-1-testing-mock-behavior)
|
|
52
|
+
|
|
53
|
+
### 2. Test-Only Methods in Production
|
|
54
|
+
Methods in production classes only used by tests. **Fix:** Move to test utilities.
|
|
55
|
+
**→** [core-anti-patterns.md](references/core-anti-patterns.md#anti-pattern-2-test-only-methods-in-production)
|
|
56
|
+
|
|
57
|
+
### 3. Mocking Without Understanding
|
|
58
|
+
Mocking without understanding dependencies/side effects. **Fix:** Understand first, mock minimally.
|
|
59
|
+
**→** [core-anti-patterns.md](references/core-anti-patterns.md#anti-pattern-3-mocking-without-understanding)
|
|
60
|
+
|
|
61
|
+
### 4. Incomplete Mocks
|
|
62
|
+
Partial mocks missing fields downstream code needs. **Fix:** Mirror complete API structure.
|
|
63
|
+
**→** [completeness-anti-patterns.md](references/completeness-anti-patterns.md#anti-pattern-4-incomplete-mocks)
|
|
64
|
+
|
|
65
|
+
### 5. Tests as Afterthought
|
|
66
|
+
Implementation "complete" without tests. **Fix:** TDD - write test first.
|
|
67
|
+
**→** [completeness-anti-patterns.md](references/completeness-anti-patterns.md#anti-pattern-5-integration-tests-as-afterthought)
|
|
68
|
+
|
|
69
|
+
## Quick Detection Checklist
|
|
70
|
+
|
|
71
|
+
Run this checklist before committing any test:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
□ Am I asserting on mock elements? (testId='*-mock')
|
|
75
|
+
→ If yes: STOP - Test real component or unmock
|
|
76
|
+
|
|
77
|
+
□ Does this method only exist for tests?
|
|
78
|
+
→ If yes: STOP - Move to test utilities
|
|
79
|
+
|
|
80
|
+
□ Do I fully understand what I'm mocking?
|
|
81
|
+
→ If no: STOP - Run with real impl first, then mock minimally
|
|
82
|
+
|
|
83
|
+
□ Is my mock missing fields the real API has?
|
|
84
|
+
→ If yes: STOP - Mirror complete API structure
|
|
85
|
+
|
|
86
|
+
□ Did I write implementation before test?
|
|
87
|
+
→ If yes: STOP - Delete impl, write test first (TDD)
|
|
88
|
+
|
|
89
|
+
□ Is mock setup >50% of test code?
|
|
90
|
+
→ If yes: Consider integration test with real components
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**See:** [detection-guide.md](references/detection-guide.md) for comprehensive red flags and warning signs.
|
|
94
|
+
|
|
95
|
+
## The Bottom Line
|
|
96
|
+
|
|
97
|
+
**Mocks are tools to isolate, not things to test.**
|
|
98
|
+
|
|
99
|
+
If you're testing mock behavior, you've gone wrong. Fix: Test real behavior or question why you're mocking at all.
|
|
100
|
+
|
|
101
|
+
**TDD prevents these patterns.** Write test first → Watch fail → Minimal implementation → Pass → Refactor.
|
|
102
|
+
|
|
103
|
+
## Navigation
|
|
104
|
+
|
|
105
|
+
### Detailed Anti-Pattern Analysis
|
|
106
|
+
- **[Core Anti-Patterns](references/core-anti-patterns.md)** - Patterns 1-3: Mock behavior, test-only methods, uninformed mocking
|
|
107
|
+
- **[Completeness Anti-Patterns](references/completeness-anti-patterns.md)** - Patterns 4-5: Incomplete mocks, tests as afterthought
|
|
108
|
+
|
|
109
|
+
### Detection & Prevention
|
|
110
|
+
- **[Detection Guide](references/detection-guide.md)** - Red flags, warning signs, gate functions
|
|
111
|
+
- **[TDD Connection](references/tdd-connection.md)** - How test-driven development prevents these patterns
|
|
112
|
+
|
|
113
|
+
### Related Skills
|
|
114
|
+
- **[test-driven-development](../test-driven-development/)** - Complete TDD workflow (prevents these patterns)
|
|
115
|
+
- **[verification-before-completion](../../../productivity/verification-before-completion/)** - Testing is part of "done"
|
|
116
|
+
|
|
117
|
+
## Key Reminders
|
|
118
|
+
|
|
119
|
+
1. **Mocks isolate, don't prove** - Test real code, not mocks
|
|
120
|
+
2. **Production ignores tests** - No test-only methods
|
|
121
|
+
3. **Understand before mocking** - Know dependencies and side effects
|
|
122
|
+
4. **Complete mocks only** - Mirror full API structure
|
|
123
|
+
5. **Tests ARE implementation** - Not optional afterthought
|
|
124
|
+
|
|
125
|
+
## Red Flags - STOP
|
|
126
|
+
|
|
127
|
+
**STOP immediately if you find yourself:**
|
|
128
|
+
- Asserting on `*-mock` test IDs
|
|
129
|
+
- Adding methods only called in test files
|
|
130
|
+
- Mocking "just to be safe" without understanding
|
|
131
|
+
- Creating mocks from memory instead of API docs
|
|
132
|
+
- Saying "tests can wait" or "ready for testing"
|
|
133
|
+
|
|
134
|
+
**When mocks become too complex:** Consider integration tests with real components. Often simpler and more valuable.
|
|
135
|
+
|
|
136
|
+
## Integration with Other Skills
|
|
137
|
+
|
|
138
|
+
**Prerequisite:** [test-driven-development](../test-driven-development/) - TDD prevents anti-patterns
|
|
139
|
+
**Complementary:** [verification-before-completion](../../../productivity/verification-before-completion/) - Tests = done
|
|
140
|
+
**Domain-specific:** webapp-testing, backend-testing for framework patterns
|
claude_mpm/skills/bundled/testing/testing-anti-patterns/references/completeness-anti-patterns.md
ADDED
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
# Completeness Anti-Patterns
|
|
2
|
+
|
|
3
|
+
Anti-patterns related to incomplete testing practices: partial mocks that hide structural dependencies, and treating tests as optional afterthoughts instead of integral parts of implementation.
|
|
4
|
+
|
|
5
|
+
## Anti-Pattern 4: Incomplete Mocks
|
|
6
|
+
|
|
7
|
+
**The violation:**
|
|
8
|
+
```typescript
|
|
9
|
+
// ❌ BAD: Partial mock - only fields you think you need
|
|
10
|
+
const mockResponse = {
|
|
11
|
+
status: 'success',
|
|
12
|
+
data: { userId: '123', name: 'Alice' }
|
|
13
|
+
// Missing: metadata that downstream code uses
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// Later: breaks when code accesses response.metadata.requestId
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Why this is wrong:**
|
|
20
|
+
- **Partial mocks hide structural assumptions** - You only mocked fields you know about
|
|
21
|
+
- **Downstream code may depend on fields you didn't include** - Silent failures
|
|
22
|
+
- **Tests pass but integration fails** - Mock incomplete, real API complete
|
|
23
|
+
- **False confidence** - Test proves nothing about real behavior
|
|
24
|
+
- **Breaking changes go undetected** - API changes don't fail tests
|
|
25
|
+
|
|
26
|
+
**The Iron Rule:** Mock the COMPLETE data structure as it exists in reality, not just fields your immediate test uses.
|
|
27
|
+
|
|
28
|
+
**Real-world impact:**
|
|
29
|
+
```typescript
|
|
30
|
+
// Your test (incomplete mock)
|
|
31
|
+
const mockUser = { id: '123', name: 'Alice' };
|
|
32
|
+
// Passes ✅
|
|
33
|
+
|
|
34
|
+
// Production code elsewhere
|
|
35
|
+
function getUserTimezone(user) {
|
|
36
|
+
return user.profile.timezone; // undefined - breaks in production!
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Complete Mock Strategy
|
|
41
|
+
|
|
42
|
+
**The fix:**
|
|
43
|
+
```typescript
|
|
44
|
+
// ✅ GOOD: Mirror real API completeness
|
|
45
|
+
const mockResponse = {
|
|
46
|
+
status: 'success',
|
|
47
|
+
data: {
|
|
48
|
+
userId: '123',
|
|
49
|
+
name: 'Alice',
|
|
50
|
+
email: 'alice@example.com',
|
|
51
|
+
profile: {
|
|
52
|
+
timezone: 'America/New_York',
|
|
53
|
+
locale: 'en-US',
|
|
54
|
+
avatar: 'https://...'
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
metadata: {
|
|
58
|
+
requestId: 'req-789',
|
|
59
|
+
timestamp: 1234567890,
|
|
60
|
+
version: 'v2'
|
|
61
|
+
}
|
|
62
|
+
// All fields real API returns
|
|
63
|
+
};
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### How to Create Complete Mocks
|
|
67
|
+
|
|
68
|
+
**Step 1: Reference real API documentation**
|
|
69
|
+
```typescript
|
|
70
|
+
// ❌ BAD - mocking from memory
|
|
71
|
+
const mock = { id: 1, name: 'test' };
|
|
72
|
+
|
|
73
|
+
// ✅ GOOD - reference API docs
|
|
74
|
+
// From API docs: GET /api/users/:id returns:
|
|
75
|
+
// {
|
|
76
|
+
// id: number,
|
|
77
|
+
// name: string,
|
|
78
|
+
// email: string,
|
|
79
|
+
// createdAt: ISO8601,
|
|
80
|
+
// profile: { ... },
|
|
81
|
+
// permissions: string[]
|
|
82
|
+
// }
|
|
83
|
+
|
|
84
|
+
const mock = {
|
|
85
|
+
id: 1,
|
|
86
|
+
name: 'test',
|
|
87
|
+
email: 'test@example.com',
|
|
88
|
+
createdAt: '2024-01-01T00:00:00Z',
|
|
89
|
+
profile: { /* complete profile */ },
|
|
90
|
+
permissions: ['read', 'write']
|
|
91
|
+
};
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Step 2: Use TypeScript types**
|
|
95
|
+
```typescript
|
|
96
|
+
// ✅ TypeScript ensures completeness
|
|
97
|
+
interface User {
|
|
98
|
+
id: string;
|
|
99
|
+
name: string;
|
|
100
|
+
email: string;
|
|
101
|
+
profile: UserProfile;
|
|
102
|
+
metadata: UserMetadata;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// TypeScript error if incomplete
|
|
106
|
+
const mockUser: User = {
|
|
107
|
+
id: '123',
|
|
108
|
+
name: 'Alice'
|
|
109
|
+
// Error: Missing email, profile, metadata
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// Must be complete
|
|
113
|
+
const mockUser: User = {
|
|
114
|
+
id: '123',
|
|
115
|
+
name: 'Alice',
|
|
116
|
+
email: 'alice@example.com',
|
|
117
|
+
profile: { timezone: 'UTC', locale: 'en' },
|
|
118
|
+
metadata: { createdAt: '2024-01-01T00:00:00Z' }
|
|
119
|
+
};
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Step 3: Extract mock factories**
|
|
123
|
+
```typescript
|
|
124
|
+
// ✅ Reusable complete mocks
|
|
125
|
+
// test-utils/factories/user.ts
|
|
126
|
+
export function createMockUser(overrides?: Partial<User>): User {
|
|
127
|
+
return {
|
|
128
|
+
id: '123',
|
|
129
|
+
name: 'Test User',
|
|
130
|
+
email: 'test@example.com',
|
|
131
|
+
profile: {
|
|
132
|
+
timezone: 'UTC',
|
|
133
|
+
locale: 'en-US',
|
|
134
|
+
avatar: null
|
|
135
|
+
},
|
|
136
|
+
metadata: {
|
|
137
|
+
createdAt: '2024-01-01T00:00:00Z',
|
|
138
|
+
updatedAt: '2024-01-01T00:00:00Z',
|
|
139
|
+
version: 1
|
|
140
|
+
},
|
|
141
|
+
permissions: ['read'],
|
|
142
|
+
...overrides // Allow customization
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Usage
|
|
147
|
+
const user = createMockUser({ name: 'Alice' });
|
|
148
|
+
// All fields present, name overridden
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Detecting Incomplete Mocks
|
|
152
|
+
|
|
153
|
+
**Red flags:**
|
|
154
|
+
- Creating mocks without referencing API docs
|
|
155
|
+
- TypeScript `any` or `Partial<T>` for mocks
|
|
156
|
+
- Different tests have different mock shapes for same type
|
|
157
|
+
- Mock has fewer fields than real API
|
|
158
|
+
- Comments like "add fields as needed"
|
|
159
|
+
|
|
160
|
+
**Gate Function:**
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
BEFORE creating mock responses:
|
|
164
|
+
Check: "What fields does the real API response contain?"
|
|
165
|
+
|
|
166
|
+
Actions:
|
|
167
|
+
1. Open API documentation or OpenAPI spec
|
|
168
|
+
2. List ALL fields in response
|
|
169
|
+
3. Include ALL fields in mock (use TypeScript types)
|
|
170
|
+
4. Verify mock matches real response schema completely
|
|
171
|
+
|
|
172
|
+
Critical:
|
|
173
|
+
If you're creating a mock, you must understand the ENTIRE structure
|
|
174
|
+
Partial mocks fail silently when code depends on omitted fields
|
|
175
|
+
|
|
176
|
+
If uncertain:
|
|
177
|
+
- Include all documented fields
|
|
178
|
+
- Use TypeScript interfaces to enforce completeness
|
|
179
|
+
- Create factory functions for reusable complete mocks
|
|
180
|
+
|
|
181
|
+
Red flags:
|
|
182
|
+
- "I'll add more fields later"
|
|
183
|
+
- "Just mocking what I need"
|
|
184
|
+
- Creating mock from memory
|
|
185
|
+
- Different mock shapes for same entity
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Common Incomplete Mock Scenarios
|
|
189
|
+
|
|
190
|
+
**Scenario 1: Nested objects**
|
|
191
|
+
```typescript
|
|
192
|
+
// ❌ BAD - incomplete nesting
|
|
193
|
+
const mockUser = {
|
|
194
|
+
id: '123',
|
|
195
|
+
profile: { name: 'Alice' } // Missing profile.timezone, profile.locale
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// ✅ GOOD - complete nesting
|
|
199
|
+
const mockUser = {
|
|
200
|
+
id: '123',
|
|
201
|
+
profile: {
|
|
202
|
+
name: 'Alice',
|
|
203
|
+
timezone: 'UTC',
|
|
204
|
+
locale: 'en-US',
|
|
205
|
+
avatar: null,
|
|
206
|
+
bio: null
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**Scenario 2: Arrays**
|
|
212
|
+
```typescript
|
|
213
|
+
// ❌ BAD - empty array when real data has items
|
|
214
|
+
const mockResponse = {
|
|
215
|
+
users: [] // Real API always has pagination metadata
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// ✅ GOOD - realistic array with metadata
|
|
219
|
+
const mockResponse = {
|
|
220
|
+
users: [
|
|
221
|
+
{ id: '1', name: 'Alice', /* complete user */ },
|
|
222
|
+
{ id: '2', name: 'Bob', /* complete user */ }
|
|
223
|
+
],
|
|
224
|
+
pagination: {
|
|
225
|
+
total: 2,
|
|
226
|
+
page: 1,
|
|
227
|
+
perPage: 10,
|
|
228
|
+
hasNext: false
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**Scenario 3: Optional fields**
|
|
234
|
+
```typescript
|
|
235
|
+
// ❌ BAD - omitting optional fields
|
|
236
|
+
const mockUser = {
|
|
237
|
+
id: '123',
|
|
238
|
+
name: 'Alice'
|
|
239
|
+
// Omitted optional fields - downstream code may check them
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
// ✅ GOOD - include optional fields (as null/undefined)
|
|
243
|
+
const mockUser = {
|
|
244
|
+
id: '123',
|
|
245
|
+
name: 'Alice',
|
|
246
|
+
bio: null, // Optional field explicitly null
|
|
247
|
+
website: undefined, // Optional field explicitly undefined
|
|
248
|
+
avatar: null
|
|
249
|
+
};
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Mock Completeness Levels
|
|
253
|
+
|
|
254
|
+
**Level 1: Minimal (AVOID)**
|
|
255
|
+
```typescript
|
|
256
|
+
// Only immediate test needs
|
|
257
|
+
const mock = { id: '123' };
|
|
258
|
+
// Risk: High - downstream code breaks
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
**Level 2: Partial (RISKY)**
|
|
262
|
+
```typescript
|
|
263
|
+
// Common fields included
|
|
264
|
+
const mock = { id: '123', name: 'Alice', email: 'alice@example.com' };
|
|
265
|
+
// Risk: Medium - missing nested/optional fields
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
**Level 3: Complete (REQUIRED)**
|
|
269
|
+
```typescript
|
|
270
|
+
// All fields from API spec
|
|
271
|
+
const mock = {
|
|
272
|
+
id: '123',
|
|
273
|
+
name: 'Alice',
|
|
274
|
+
email: 'alice@example.com',
|
|
275
|
+
profile: { /* complete */ },
|
|
276
|
+
metadata: { /* complete */ },
|
|
277
|
+
permissions: ['read']
|
|
278
|
+
};
|
|
279
|
+
// Risk: Low - matches real API
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
**Level 4: Factory-based (BEST)**
|
|
283
|
+
```typescript
|
|
284
|
+
// Reusable factory with defaults
|
|
285
|
+
const mock = createMockUser({ name: 'Alice' });
|
|
286
|
+
// Risk: Minimal - centralized, typed, complete
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Anti-Pattern 5: Integration Tests as Afterthought
|
|
290
|
+
|
|
291
|
+
**The violation:**
|
|
292
|
+
```
|
|
293
|
+
✅ Implementation complete
|
|
294
|
+
❌ No tests written
|
|
295
|
+
"Ready for testing"
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
**Why this is wrong:**
|
|
299
|
+
- Testing is part of implementation, not optional follow-up
|
|
300
|
+
- TDD would have caught this
|
|
301
|
+
- Can't claim complete without tests
|
|
302
|
+
- Tests written after code are biased toward existing implementation
|
|
303
|
+
- Missing tests = incomplete feature
|
|
304
|
+
- Technical debt from day one
|
|
305
|
+
|
|
306
|
+
**The fix:**
|
|
307
|
+
```
|
|
308
|
+
TDD cycle:
|
|
309
|
+
1. Write failing test
|
|
310
|
+
2. Watch it fail (verify)
|
|
311
|
+
3. Write minimal code to pass
|
|
312
|
+
4. Watch it pass (verify)
|
|
313
|
+
5. Refactor
|
|
314
|
+
6. THEN claim complete
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Why Tests Must Come First
|
|
318
|
+
|
|
319
|
+
**Tests-after problems:**
|
|
320
|
+
|
|
321
|
+
1. **Implementation bias**
|
|
322
|
+
- Tests confirm what code does, not what it should do
|
|
323
|
+
- Bugs baked into tests
|
|
324
|
+
- Missing edge cases
|
|
325
|
+
|
|
326
|
+
2. **Design issues**
|
|
327
|
+
- Code hard to test (not designed for testability)
|
|
328
|
+
- Tight coupling discovered too late
|
|
329
|
+
- Refactoring required to make testable
|
|
330
|
+
|
|
331
|
+
3. **Coverage gaps**
|
|
332
|
+
- Temptation to skip "hard to test" paths
|
|
333
|
+
- Error handling overlooked
|
|
334
|
+
- Edge cases ignored
|
|
335
|
+
|
|
336
|
+
4. **False completion**
|
|
337
|
+
- Feature seems done but untested
|
|
338
|
+
- Integration issues discovered late
|
|
339
|
+
- Delayed feedback loop
|
|
340
|
+
|
|
341
|
+
**Tests-first benefits:**
|
|
342
|
+
|
|
343
|
+
1. **Design driver**
|
|
344
|
+
- Forces testable design upfront
|
|
345
|
+
- Identifies coupling before writing code
|
|
346
|
+
- API designed from consumer perspective
|
|
347
|
+
|
|
348
|
+
2. **Verification**
|
|
349
|
+
- Confirms implementation matches requirements
|
|
350
|
+
- Catches bugs immediately
|
|
351
|
+
- Documents expected behavior
|
|
352
|
+
|
|
353
|
+
3. **Confidence**
|
|
354
|
+
- Safe refactoring
|
|
355
|
+
- Regression prevention
|
|
356
|
+
- Living documentation
|
|
357
|
+
|
|
358
|
+
### Integration Testing Strategy
|
|
359
|
+
|
|
360
|
+
**When to write integration tests:**
|
|
361
|
+
|
|
362
|
+
- **Before implementation** (TDD approach)
|
|
363
|
+
```typescript
|
|
364
|
+
// 1. Write failing integration test
|
|
365
|
+
test('user registration flow', async () => {
|
|
366
|
+
const response = await api.post('/register', userData);
|
|
367
|
+
expect(response.status).toBe(201);
|
|
368
|
+
expect(response.body.user).toMatchObject(userData);
|
|
369
|
+
});
|
|
370
|
+
// Test fails - endpoint doesn't exist
|
|
371
|
+
|
|
372
|
+
// 2. Implement endpoint
|
|
373
|
+
// 3. Test passes
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
- **Alongside unit tests** (test pyramid)
|
|
377
|
+
- Unit tests: Fast, isolated, many
|
|
378
|
+
- Integration tests: Realistic, end-to-end, fewer
|
|
379
|
+
- Both written before/during implementation
|
|
380
|
+
|
|
381
|
+
**Types of integration tests:**
|
|
382
|
+
|
|
383
|
+
1. **API integration tests**
|
|
384
|
+
```typescript
|
|
385
|
+
test('POST /api/users creates user', async () => {
|
|
386
|
+
const response = await request(app)
|
|
387
|
+
.post('/api/users')
|
|
388
|
+
.send({ name: 'Alice', email: 'alice@example.com' });
|
|
389
|
+
|
|
390
|
+
expect(response.status).toBe(201);
|
|
391
|
+
expect(response.body).toMatchObject({
|
|
392
|
+
id: expect.any(String),
|
|
393
|
+
name: 'Alice',
|
|
394
|
+
email: 'alice@example.com'
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
// Verify database
|
|
398
|
+
const user = await db.users.findById(response.body.id);
|
|
399
|
+
expect(user).toBeDefined();
|
|
400
|
+
});
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
2. **Database integration tests**
|
|
404
|
+
```typescript
|
|
405
|
+
test('user repository saves and retrieves users', async () => {
|
|
406
|
+
const user = await userRepo.create({
|
|
407
|
+
name: 'Alice',
|
|
408
|
+
email: 'alice@example.com'
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
const retrieved = await userRepo.findById(user.id);
|
|
412
|
+
expect(retrieved).toEqual(user);
|
|
413
|
+
});
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
3. **Component integration tests**
|
|
417
|
+
```typescript
|
|
418
|
+
test('UserForm submits to API', async () => {
|
|
419
|
+
render(<UserForm />);
|
|
420
|
+
|
|
421
|
+
fireEvent.change(screen.getByLabelText('Name'), {
|
|
422
|
+
target: { value: 'Alice' }
|
|
423
|
+
});
|
|
424
|
+
fireEvent.click(screen.getByText('Submit'));
|
|
425
|
+
|
|
426
|
+
await waitFor(() => {
|
|
427
|
+
expect(mockApi.post).toHaveBeenCalledWith('/users', {
|
|
428
|
+
name: 'Alice'
|
|
429
|
+
});
|
|
430
|
+
});
|
|
431
|
+
});
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### Test Completeness Checklist
|
|
435
|
+
|
|
436
|
+
**Before claiming implementation complete:**
|
|
437
|
+
|
|
438
|
+
```
|
|
439
|
+
□ Unit tests written and passing
|
|
440
|
+
- All public functions tested
|
|
441
|
+
- Edge cases covered
|
|
442
|
+
- Error conditions tested
|
|
443
|
+
|
|
444
|
+
□ Integration tests written and passing
|
|
445
|
+
- End-to-end flows tested
|
|
446
|
+
- External dependencies tested
|
|
447
|
+
- Error handling tested
|
|
448
|
+
|
|
449
|
+
□ Test coverage meets threshold (e.g., 80%)
|
|
450
|
+
- Line coverage
|
|
451
|
+
- Branch coverage
|
|
452
|
+
- Critical paths covered
|
|
453
|
+
|
|
454
|
+
□ Tests run in CI/CD pipeline
|
|
455
|
+
- Automated on commits
|
|
456
|
+
- Blocks merge if failing
|
|
457
|
+
|
|
458
|
+
□ Tests document behavior
|
|
459
|
+
- Clear test names
|
|
460
|
+
- Meaningful assertions
|
|
461
|
+
- Edge cases explained
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
### Gate Function
|
|
465
|
+
|
|
466
|
+
```
|
|
467
|
+
BEFORE claiming implementation complete:
|
|
468
|
+
Ask: "Are tests written?"
|
|
469
|
+
|
|
470
|
+
IF no:
|
|
471
|
+
STOP - Not complete
|
|
472
|
+
Write tests before continuing
|
|
473
|
+
|
|
474
|
+
Ask: "Do tests cover all requirements?"
|
|
475
|
+
|
|
476
|
+
IF no:
|
|
477
|
+
STOP - Incomplete testing
|
|
478
|
+
Add missing test cases
|
|
479
|
+
|
|
480
|
+
Ask: "Did I follow TDD (test-first)?"
|
|
481
|
+
|
|
482
|
+
IF no:
|
|
483
|
+
WARNING - Consider rewriting with TDD
|
|
484
|
+
Tests may be implementation-biased
|
|
485
|
+
|
|
486
|
+
Ask: "Do integration tests pass?"
|
|
487
|
+
|
|
488
|
+
IF no:
|
|
489
|
+
STOP - Not ready for integration
|
|
490
|
+
Fix integration issues
|
|
491
|
+
|
|
492
|
+
Definition of "complete":
|
|
493
|
+
✅ Unit tests written and passing
|
|
494
|
+
✅ Integration tests written and passing
|
|
495
|
+
✅ Coverage meets threshold
|
|
496
|
+
✅ Tests run in CI/CD
|
|
497
|
+
✅ All requirements verified
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
### Recovery: Adding Tests After Implementation
|
|
501
|
+
|
|
502
|
+
**If tests weren't written first (damage control):**
|
|
503
|
+
|
|
504
|
+
1. **Stop adding features** - Don't dig deeper hole
|
|
505
|
+
2. **Write tests for existing code** - Start with critical paths
|
|
506
|
+
3. **Refactor for testability** - Decouple as needed
|
|
507
|
+
4. **Adopt TDD going forward** - Prevent future occurrence
|
|
508
|
+
|
|
509
|
+
**Prioritization:**
|
|
510
|
+
- **High priority:** Critical business logic, security, data integrity
|
|
511
|
+
- **Medium priority:** Common user flows, API endpoints
|
|
512
|
+
- **Low priority:** UI styling, configuration, one-off scripts
|
|
513
|
+
|
|
514
|
+
**Approach:**
|
|
515
|
+
```typescript
|
|
516
|
+
// 1. Write characterization tests (document current behavior)
|
|
517
|
+
test('current behavior: user registration', async () => {
|
|
518
|
+
const result = await registerUser(userData);
|
|
519
|
+
// Document what currently happens
|
|
520
|
+
expect(result).toMatchSnapshot();
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
// 2. Add specific behavior tests
|
|
524
|
+
test('user registration validates email', async () => {
|
|
525
|
+
await expect(registerUser({ email: 'invalid' }))
|
|
526
|
+
.rejects.toThrow('Invalid email');
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
// 3. Refactor safely with test coverage
|
|
530
|
+
// Now can refactor with confidence
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
## Prevention Through TDD
|
|
534
|
+
|
|
535
|
+
**How TDD prevents completeness anti-patterns:**
|
|
536
|
+
|
|
537
|
+
1. **Incomplete mocks**
|
|
538
|
+
- Writing test first forces understanding of data structures
|
|
539
|
+
- Failing test shows what fields are needed
|
|
540
|
+
- Implementation reveals missing mock fields immediately
|
|
541
|
+
|
|
542
|
+
2. **Tests as afterthought**
|
|
543
|
+
- TDD makes tests part of implementation process
|
|
544
|
+
- Can't write implementation without test
|
|
545
|
+
- Test-first is the workflow, not optional step
|
|
546
|
+
|
|
547
|
+
**TDD workflow enforces:**
|
|
548
|
+
- Complete understanding of requirements (to write test)
|
|
549
|
+
- Complete data structures (test fails if incomplete)
|
|
550
|
+
- Complete coverage (tests drive implementation)
|
|
551
|
+
|
|
552
|
+
See [test-driven-development skill](../../test-driven-development/) for complete TDD workflow.
|
|
553
|
+
|
|
554
|
+
## Real-World Impact
|
|
555
|
+
|
|
556
|
+
**Incomplete mocks:**
|
|
557
|
+
- Tests pass, production breaks
|
|
558
|
+
- Integration issues discovered late
|
|
559
|
+
- False confidence in test suite
|
|
560
|
+
- Difficult debugging (mock ≠ reality)
|
|
561
|
+
|
|
562
|
+
**Tests as afterthought:**
|
|
563
|
+
- Bugs escape to production
|
|
564
|
+
- Implementation hard to test (design issues)
|
|
565
|
+
- Coverage gaps
|
|
566
|
+
- Technical debt from day one
|
|
567
|
+
|
|
568
|
+
**With complete approach:**
|
|
569
|
+
- Tests catch integration issues early
|
|
570
|
+
- High confidence in test suite
|
|
571
|
+
- Testable design from start
|
|
572
|
+
- Complete feature = tested feature
|