@heyai-rules/pilo-masterkit 1.2.2
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.
- package/.agent/agents/PILO_MASTER.md +77 -0
- package/.agent/agents/architect.md +211 -0
- package/.agent/agents/backend-specialist.md +263 -0
- package/.agent/agents/build-error-resolver.md +114 -0
- package/.agent/agents/chief-of-staff.md +151 -0
- package/.agent/agents/code-archaeologist.md +106 -0
- package/.agent/agents/code-reviewer.md +237 -0
- package/.agent/agents/cpp-build-resolver.md +90 -0
- package/.agent/agents/cpp-reviewer.md +72 -0
- package/.agent/agents/database-architect.md +226 -0
- package/.agent/agents/database-reviewer.md +91 -0
- package/.agent/agents/debugger.md +225 -0
- package/.agent/agents/devops-engineer.md +242 -0
- package/.agent/agents/doc-updater.md +107 -0
- package/.agent/agents/docs-lookup.md +68 -0
- package/.agent/agents/documentation-writer.md +104 -0
- package/.agent/agents/e2e-runner.md +107 -0
- package/.agent/agents/explorer-agent.md +73 -0
- package/.agent/agents/flutter-reviewer.md +243 -0
- package/.agent/agents/frontend-specialist.md +593 -0
- package/.agent/agents/game-developer.md +162 -0
- package/.agent/agents/go-build-resolver.md +94 -0
- package/.agent/agents/go-reviewer.md +76 -0
- package/.agent/agents/harness-optimizer.md +35 -0
- package/.agent/agents/java-build-resolver.md +153 -0
- package/.agent/agents/java-reviewer.md +92 -0
- package/.agent/agents/kotlin-build-resolver.md +118 -0
- package/.agent/agents/kotlin-reviewer.md +159 -0
- package/.agent/agents/loop-operator.md +36 -0
- package/.agent/agents/mobile-developer.md +377 -0
- package/.agent/agents/orchestrator.md +416 -0
- package/.agent/agents/penetration-tester.md +188 -0
- package/.agent/agents/performance-optimizer.md +187 -0
- package/.agent/agents/planner.md +212 -0
- package/.agent/agents/product-manager.md +112 -0
- package/.agent/agents/product-owner.md +95 -0
- package/.agent/agents/project-planner.md +406 -0
- package/.agent/agents/python-reviewer.md +98 -0
- package/.agent/agents/pytorch-build-resolver.md +120 -0
- package/.agent/agents/qa-automation-engineer.md +103 -0
- package/.agent/agents/refactor-cleaner.md +85 -0
- package/.agent/agents/rust-build-resolver.md +148 -0
- package/.agent/agents/rust-reviewer.md +94 -0
- package/.agent/agents/security-auditor.md +170 -0
- package/.agent/agents/security-reviewer.md +108 -0
- package/.agent/agents/seo-specialist.md +111 -0
- package/.agent/agents/tdd-guide.md +91 -0
- package/.agent/agents/test-engineer.md +158 -0
- package/.agent/agents/typescript-reviewer.md +112 -0
- package/.agent/rules/ARCHITECTURAL_BLUEPRINTS.md +62 -0
- package/.agent/rules/CODE_CRAFTSMANSHIP.md +69 -0
- package/.agent/rules/CORE_RULES.md +72 -0
- package/.agent/rules/PROJECT_MAP.md +58 -0
- package/.agent/rules/QUALITY_ASSURANCE.md +54 -0
- package/.agent/rules/SECURITY_ARMOR.md +44 -0
- package/.agent/rules/VERSION_ORCHESTRATION.md +64 -0
- package/.agent/rules/WORKFLOW_ORCHESTRATION.md +55 -0
- package/.agent/scripts/auto_preview.py +148 -0
- package/.agent/scripts/checklist.py +217 -0
- package/.agent/scripts/session_manager.py +120 -0
- package/.agent/scripts/verify_all.py +327 -0
- package/.agent/skills/api-patterns/SKILL.md +81 -0
- package/.agent/skills/api-patterns/api-style.md +42 -0
- package/.agent/skills/api-patterns/auth.md +24 -0
- package/.agent/skills/api-patterns/documentation.md +26 -0
- package/.agent/skills/api-patterns/graphql.md +41 -0
- package/.agent/skills/api-patterns/rate-limiting.md +31 -0
- package/.agent/skills/api-patterns/response.md +37 -0
- package/.agent/skills/api-patterns/rest.md +40 -0
- package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
- package/.agent/skills/api-patterns/security-testing.md +122 -0
- package/.agent/skills/api-patterns/trpc.md +41 -0
- package/.agent/skills/api-patterns/versioning.md +22 -0
- package/.agent/skills/app-builder/SKILL.md +75 -0
- package/.agent/skills/app-builder/agent-coordination.md +71 -0
- package/.agent/skills/app-builder/feature-building.md +53 -0
- package/.agent/skills/app-builder/project-detection.md +34 -0
- package/.agent/skills/app-builder/scaffolding.md +118 -0
- package/.agent/skills/app-builder/tech-stack.md +41 -0
- package/.agent/skills/app-builder/templates/SKILL.md +39 -0
- package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
- package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
- package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
- package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
- package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
- package/.agent/skills/architecture/SKILL.md +55 -0
- package/.agent/skills/architecture/context-discovery.md +43 -0
- package/.agent/skills/architecture/examples.md +94 -0
- package/.agent/skills/architecture/pattern-selection.md +68 -0
- package/.agent/skills/architecture/patterns-reference.md +50 -0
- package/.agent/skills/architecture/trade-off-analysis.md +77 -0
- package/.agent/skills/bash-linux/SKILL.md +199 -0
- package/.agent/skills/behavioral-modes/SKILL.md +242 -0
- package/.agent/skills/brainstorming/SKILL.md +163 -0
- package/.agent/skills/brainstorming/dynamic-questioning.md +350 -0
- package/.agent/skills/clean-code/SKILL.md +201 -0
- package/.agent/skills/code-review-checklist/SKILL.md +109 -0
- package/.agent/skills/database-design/SKILL.md +52 -0
- package/.agent/skills/database-design/database-selection.md +43 -0
- package/.agent/skills/database-design/indexing.md +39 -0
- package/.agent/skills/database-design/migrations.md +48 -0
- package/.agent/skills/database-design/optimization.md +36 -0
- package/.agent/skills/database-design/orm-selection.md +30 -0
- package/.agent/skills/database-design/schema-design.md +56 -0
- package/.agent/skills/database-design/scripts/schema_validator.py +172 -0
- package/.agent/skills/deployment-procedures/SKILL.md +241 -0
- package/.agent/skills/doc.md +177 -0
- package/.agent/skills/documentation-templates/SKILL.md +194 -0
- package/.agent/skills/frontend-design/SKILL.md +452 -0
- package/.agent/skills/frontend-design/animation-guide.md +331 -0
- package/.agent/skills/frontend-design/color-system.md +311 -0
- package/.agent/skills/frontend-design/decision-trees.md +418 -0
- package/.agent/skills/frontend-design/motion-graphics.md +306 -0
- package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
- package/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
- package/.agent/skills/frontend-design/typography-system.md +345 -0
- package/.agent/skills/frontend-design/ux-psychology.md +1116 -0
- package/.agent/skills/frontend-design/visual-effects.md +383 -0
- package/.agent/skills/game-development/2d-games/SKILL.md +119 -0
- package/.agent/skills/game-development/3d-games/SKILL.md +135 -0
- package/.agent/skills/game-development/SKILL.md +167 -0
- package/.agent/skills/game-development/game-art/SKILL.md +185 -0
- package/.agent/skills/game-development/game-audio/SKILL.md +190 -0
- package/.agent/skills/game-development/game-design/SKILL.md +129 -0
- package/.agent/skills/game-development/mobile-games/SKILL.md +108 -0
- package/.agent/skills/game-development/multiplayer/SKILL.md +132 -0
- package/.agent/skills/game-development/pc-games/SKILL.md +144 -0
- package/.agent/skills/game-development/vr-ar/SKILL.md +123 -0
- package/.agent/skills/game-development/web-games/SKILL.md +150 -0
- package/.agent/skills/geo-fundamentals/SKILL.md +156 -0
- package/.agent/skills/geo-fundamentals/scripts/geo_checker.py +289 -0
- package/.agent/skills/i18n-localization/SKILL.md +154 -0
- package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
- package/.agent/skills/intelligent-routing/SKILL.md +335 -0
- package/.agent/skills/lint-and-validate/SKILL.md +45 -0
- package/.agent/skills/lint-and-validate/scripts/lint_runner.py +184 -0
- package/.agent/skills/lint-and-validate/scripts/type_coverage.py +173 -0
- package/.agent/skills/mcp-builder/SKILL.md +176 -0
- package/.agent/skills/mobile-design/SKILL.md +394 -0
- package/.agent/skills/mobile-design/decision-trees.md +516 -0
- package/.agent/skills/mobile-design/mobile-backend.md +491 -0
- package/.agent/skills/mobile-design/mobile-color-system.md +420 -0
- package/.agent/skills/mobile-design/mobile-debugging.md +122 -0
- package/.agent/skills/mobile-design/mobile-design-thinking.md +357 -0
- package/.agent/skills/mobile-design/mobile-navigation.md +458 -0
- package/.agent/skills/mobile-design/mobile-performance.md +767 -0
- package/.agent/skills/mobile-design/mobile-testing.md +356 -0
- package/.agent/skills/mobile-design/mobile-typography.md +433 -0
- package/.agent/skills/mobile-design/platform-android.md +666 -0
- package/.agent/skills/mobile-design/platform-ios.md +561 -0
- package/.agent/skills/mobile-design/scripts/mobile_audit.py +670 -0
- package/.agent/skills/mobile-design/touch-psychology.md +537 -0
- package/.agent/skills/nextjs-react-expert/1-async-eliminating-waterfalls.md +351 -0
- package/.agent/skills/nextjs-react-expert/2-bundle-bundle-size-optimization.md +240 -0
- package/.agent/skills/nextjs-react-expert/3-server-server-side-performance.md +490 -0
- package/.agent/skills/nextjs-react-expert/4-client-client-side-data-fetching.md +264 -0
- package/.agent/skills/nextjs-react-expert/5-rerender-re-render-optimization.md +581 -0
- package/.agent/skills/nextjs-react-expert/6-rendering-rendering-performance.md +432 -0
- package/.agent/skills/nextjs-react-expert/7-js-javascript-performance.md +684 -0
- package/.agent/skills/nextjs-react-expert/8-advanced-advanced-patterns.md +150 -0
- package/.agent/skills/nextjs-react-expert/9-cache-components.md +103 -0
- package/.agent/skills/nextjs-react-expert/SKILL.md +293 -0
- package/.agent/skills/nextjs-react-expert/scripts/convert_rules.py +222 -0
- package/.agent/skills/nextjs-react-expert/scripts/react_performance_checker.py +252 -0
- package/.agent/skills/nodejs-best-practices/SKILL.md +333 -0
- package/.agent/skills/parallel-agents/SKILL.md +175 -0
- package/.agent/skills/performance-profiling/SKILL.md +143 -0
- package/.agent/skills/performance-profiling/scripts/lighthouse_audit.py +76 -0
- package/.agent/skills/plan-writing/SKILL.md +152 -0
- package/.agent/skills/powershell-windows/SKILL.md +167 -0
- package/.agent/skills/python-patterns/SKILL.md +441 -0
- package/.agent/skills/red-team-tactics/SKILL.md +199 -0
- package/.agent/skills/rust-pro/SKILL.md +176 -0
- package/.agent/skills/seo-fundamentals/SKILL.md +129 -0
- package/.agent/skills/seo-fundamentals/scripts/seo_checker.py +219 -0
- package/.agent/skills/server-management/SKILL.md +161 -0
- package/.agent/skills/systematic-debugging/SKILL.md +109 -0
- package/.agent/skills/tailwind-patterns/SKILL.md +269 -0
- package/.agent/skills/tdd-workflow/SKILL.md +149 -0
- package/.agent/skills/testing-patterns/SKILL.md +178 -0
- package/.agent/skills/testing-patterns/scripts/test_runner.py +219 -0
- package/.agent/skills/ui-ux-pro-max/SKILL.md +292 -0
- package/.agent/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/.agent/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/.agent/skills/ui-ux-pro-max/data/icons.csv +101 -0
- package/.agent/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/.agent/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/.agent/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/.agent/skills/ui-ux-pro-max/data/styles.csv +68 -0
- package/.agent/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/.agent/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/.agent/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/.agent/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/.agent/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-314.pyc +0 -0
- package/.agent/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-314.pyc +0 -0
- package/.agent/skills/ui-ux-pro-max/scripts/__pycache__/search.cpython-314.pyc +0 -0
- package/.agent/skills/ui-ux-pro-max/scripts/core.py +253 -0
- package/.agent/skills/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/.agent/skills/ui-ux-pro-max/scripts/search.py +114 -0
- package/.agent/skills/vulnerability-scanner/SKILL.md +276 -0
- package/.agent/skills/vulnerability-scanner/checklists.md +121 -0
- package/.agent/skills/vulnerability-scanner/scripts/security_scan.py +458 -0
- package/.agent/skills/web-design-guidelines/SKILL.md +57 -0
- package/.agent/skills/webapp-testing/SKILL.md +187 -0
- package/.agent/skills/webapp-testing/scripts/playwright_runner.py +173 -0
- package/.agent/tasks/lessons.md +40 -0
- package/.agent/tasks/todo.md +33 -0
- package/.agent/workflows/aside.md +164 -0
- package/.agent/workflows/brainstorm.md +113 -0
- package/.agent/workflows/build-fix.md +62 -0
- package/.agent/workflows/checkpoint.md +74 -0
- package/.agent/workflows/claw.md +51 -0
- package/.agent/workflows/code-review.md +40 -0
- package/.agent/workflows/context-budget.md +29 -0
- package/.agent/workflows/cpp-build.md +173 -0
- package/.agent/workflows/cpp-review.md +132 -0
- package/.agent/workflows/cpp-test.md +251 -0
- package/.agent/workflows/create.md +59 -0
- package/.agent/workflows/debug.md +103 -0
- package/.agent/workflows/deploy.md +176 -0
- package/.agent/workflows/devfleet.md +92 -0
- package/.agent/workflows/docs.md +31 -0
- package/.agent/workflows/e2e.md +365 -0
- package/.agent/workflows/enhance.md +63 -0
- package/.agent/workflows/eval.md +120 -0
- package/.agent/workflows/evolve.md +178 -0
- package/.agent/workflows/go-build.md +183 -0
- package/.agent/workflows/go-review.md +148 -0
- package/.agent/workflows/go-test.md +268 -0
- package/.agent/workflows/gradle-build.md +70 -0
- package/.agent/workflows/harness-audit.md +71 -0
- package/.agent/workflows/init-docs.md +46 -0
- package/.agent/workflows/instinct-export.md +66 -0
- package/.agent/workflows/instinct-import.md +114 -0
- package/.agent/workflows/instinct-status.md +59 -0
- package/.agent/workflows/kotlin-build.md +174 -0
- package/.agent/workflows/kotlin-review.md +140 -0
- package/.agent/workflows/kotlin-test.md +312 -0
- package/.agent/workflows/learn-eval.md +116 -0
- package/.agent/workflows/learn.md +70 -0
- package/.agent/workflows/loop-start.md +32 -0
- package/.agent/workflows/loop-status.md +24 -0
- package/.agent/workflows/model-route.md +26 -0
- package/.agent/workflows/multi-backend.md +158 -0
- package/.agent/workflows/multi-execute.md +315 -0
- package/.agent/workflows/multi-frontend.md +158 -0
- package/.agent/workflows/multi-plan.md +268 -0
- package/.agent/workflows/multi-workflow.md +191 -0
- package/.agent/workflows/orchestrate.md +231 -0
- package/.agent/workflows/plan.md +115 -0
- package/.agent/workflows/pm2.md +272 -0
- package/.agent/workflows/preview.md +81 -0
- package/.agent/workflows/projects.md +39 -0
- package/.agent/workflows/promote.md +41 -0
- package/.agent/workflows/prompt-optimize.md +38 -0
- package/.agent/workflows/prune.md +31 -0
- package/.agent/workflows/python-review.md +297 -0
- package/.agent/workflows/quality-gate.md +29 -0
- package/.agent/workflows/refactor-clean.md +80 -0
- package/.agent/workflows/resume-session.md +156 -0
- package/.agent/workflows/rules-distill.md +11 -0
- package/.agent/workflows/rust-build.md +187 -0
- package/.agent/workflows/rust-review.md +142 -0
- package/.agent/workflows/rust-test.md +308 -0
- package/.agent/workflows/save-session.md +275 -0
- package/.agent/workflows/sessions.md +333 -0
- package/.agent/workflows/setup-pm.md +80 -0
- package/.agent/workflows/skill-create.md +174 -0
- package/.agent/workflows/skill-health.md +54 -0
- package/.agent/workflows/status.md +86 -0
- package/.agent/workflows/tdd.md +328 -0
- package/.agent/workflows/test-coverage.md +69 -0
- package/.agent/workflows/test.md +144 -0
- package/.agent/workflows/ui-ux-pro-max.md +296 -0
- package/.agent/workflows/update-codemaps.md +72 -0
- package/.agent/workflows/update-docs.md +84 -0
- package/.agent/workflows/verify.md +59 -0
- package/LICENSE +176 -0
- package/README.md +136 -0
- package/RELEASE.md +36 -0
- package/package.json +79 -0
- package/scripts/release-check.js +55 -0
- package/src/bin/cli.js +78 -0
- package/src/lib/installer.js +140 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Start NanoClaw v2 — ECC's persistent, zero-dependency REPL with model routing, skill hot-load, branching, compaction, export, and metrics.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Claw Command
|
|
6
|
+
|
|
7
|
+
Start an interactive AI agent session with persistent markdown history and operational controls.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
node scripts/claw.js
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Or via npm:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm run claw
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Environment Variables
|
|
22
|
+
|
|
23
|
+
| Variable | Default | Description |
|
|
24
|
+
|----------|---------|-------------|
|
|
25
|
+
| `CLAW_SESSION` | `default` | Session name (alphanumeric + hyphens) |
|
|
26
|
+
| `CLAW_SKILLS` | *(empty)* | Comma-separated skills loaded at startup |
|
|
27
|
+
| `CLAW_MODEL` | `sonnet` | Default model for the session |
|
|
28
|
+
|
|
29
|
+
## REPL Commands
|
|
30
|
+
|
|
31
|
+
```text
|
|
32
|
+
/help Show help
|
|
33
|
+
/clear Clear current session history
|
|
34
|
+
/history Print full conversation history
|
|
35
|
+
/sessions List saved sessions
|
|
36
|
+
/model [name] Show/set model
|
|
37
|
+
/load <skill-name> Hot-load a skill into context
|
|
38
|
+
/branch <session-name> Branch current session
|
|
39
|
+
/search <query> Search query across sessions
|
|
40
|
+
/compact Compact old turns, keep recent context
|
|
41
|
+
/export <md|json|txt> [path] Export session
|
|
42
|
+
/metrics Show session metrics
|
|
43
|
+
exit Quit
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Notes
|
|
47
|
+
|
|
48
|
+
- NanoClaw remains zero-dependency.
|
|
49
|
+
- Sessions are stored at `~/.claude/claw/<session>.md`.
|
|
50
|
+
- Compaction keeps the most recent turns and writes a compaction header.
|
|
51
|
+
- Export supports markdown, JSON turns, and plain text.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Code Review
|
|
2
|
+
|
|
3
|
+
Comprehensive security and quality review of uncommitted changes:
|
|
4
|
+
|
|
5
|
+
1. Get changed files: git diff --name-only HEAD
|
|
6
|
+
|
|
7
|
+
2. For each changed file, check for:
|
|
8
|
+
|
|
9
|
+
**Security Issues (CRITICAL):**
|
|
10
|
+
- Hardcoded credentials, API keys, tokens
|
|
11
|
+
- SQL injection vulnerabilities
|
|
12
|
+
- XSS vulnerabilities
|
|
13
|
+
- Missing input validation
|
|
14
|
+
- Insecure dependencies
|
|
15
|
+
- Path traversal risks
|
|
16
|
+
|
|
17
|
+
**Code Quality (HIGH):**
|
|
18
|
+
- Functions > 50 lines
|
|
19
|
+
- Files > 800 lines
|
|
20
|
+
- Nesting depth > 4 levels
|
|
21
|
+
- Missing error handling
|
|
22
|
+
- console.log statements
|
|
23
|
+
- TODO/FIXME comments
|
|
24
|
+
- Missing JSDoc for public APIs
|
|
25
|
+
|
|
26
|
+
**Best Practices (MEDIUM):**
|
|
27
|
+
- Mutation patterns (use immutable instead)
|
|
28
|
+
- Emoji usage in code/comments
|
|
29
|
+
- Missing tests for new code
|
|
30
|
+
- Accessibility issues (a11y)
|
|
31
|
+
|
|
32
|
+
3. Generate report with:
|
|
33
|
+
- Severity: CRITICAL, HIGH, MEDIUM, LOW
|
|
34
|
+
- File location and line numbers
|
|
35
|
+
- Issue description
|
|
36
|
+
- Suggested fix
|
|
37
|
+
|
|
38
|
+
4. Block commit if CRITICAL or HIGH issues found
|
|
39
|
+
|
|
40
|
+
Never approve code with security vulnerabilities!
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Analyze context window usage across agents, skills, MCP servers, and rules to find optimization opportunities. Helps reduce token overhead and avoid performance warnings.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Context Budget Optimizer
|
|
6
|
+
|
|
7
|
+
Analyze your Claude Code setup's context window consumption and produce actionable recommendations to reduce token overhead.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
/context-budget [--verbose]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
- Default: summary with top recommendations
|
|
16
|
+
- `--verbose`: full breakdown per component
|
|
17
|
+
|
|
18
|
+
$ARGUMENTS
|
|
19
|
+
|
|
20
|
+
## What to Do
|
|
21
|
+
|
|
22
|
+
Run the **context-budget** skill (`skills/context-budget/SKILL.md`) with the following inputs:
|
|
23
|
+
|
|
24
|
+
1. Pass `--verbose` flag if present in `$ARGUMENTS`
|
|
25
|
+
2. Assume a 200K context window (Claude Sonnet default) unless the user specifies otherwise
|
|
26
|
+
3. Follow the skill's four phases: Inventory → Classify → Detect Issues → Report
|
|
27
|
+
4. Output the formatted Context Budget Report to the user
|
|
28
|
+
|
|
29
|
+
The skill handles all scanning logic, token estimation, issue detection, and report formatting.
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Fix C++ build errors, CMake issues, and linker problems incrementally. Invokes the cpp-build-resolver agent for minimal, surgical fixes.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# C++ Build and Fix
|
|
6
|
+
|
|
7
|
+
This command invokes the **cpp-build-resolver** agent to incrementally fix C++ build errors with minimal changes.
|
|
8
|
+
|
|
9
|
+
## What This Command Does
|
|
10
|
+
|
|
11
|
+
1. **Run Diagnostics**: Execute `cmake --build`, `clang-tidy`, `cppcheck`
|
|
12
|
+
2. **Parse Errors**: Group by file and sort by severity
|
|
13
|
+
3. **Fix Incrementally**: One error at a time
|
|
14
|
+
4. **Verify Each Fix**: Re-run build after each change
|
|
15
|
+
5. **Report Summary**: Show what was fixed and what remains
|
|
16
|
+
|
|
17
|
+
## When to Use
|
|
18
|
+
|
|
19
|
+
Use `/cpp-build` when:
|
|
20
|
+
- `cmake --build build` fails with errors
|
|
21
|
+
- Linker errors (undefined references, multiple definitions)
|
|
22
|
+
- Template instantiation failures
|
|
23
|
+
- Include/dependency issues
|
|
24
|
+
- After pulling changes that break the build
|
|
25
|
+
|
|
26
|
+
## Diagnostic Commands Run
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# CMake configure
|
|
30
|
+
cmake -B build -S .
|
|
31
|
+
|
|
32
|
+
# Build
|
|
33
|
+
cmake --build build 2>&1 | head -100
|
|
34
|
+
|
|
35
|
+
# Static analysis (if available)
|
|
36
|
+
clang-tidy src/*.cpp -- -std=c++17
|
|
37
|
+
cppcheck --enable=all src/
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Example Session
|
|
41
|
+
|
|
42
|
+
```text
|
|
43
|
+
User: /cpp-build
|
|
44
|
+
|
|
45
|
+
Agent:
|
|
46
|
+
# C++ Build Resolution
|
|
47
|
+
|
|
48
|
+
## Initial Diagnostics
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
$ cmake --build build
|
|
52
|
+
src/service/user.cpp:25:15: error: use of undeclared identifier 'UserRepository'
|
|
53
|
+
src/handler/api.cpp:42:9: error: no matching function for call to 'process'
|
|
54
|
+
src/handler/api.cpp:58:1: error: non-void function does not return a value
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Errors found: 3
|
|
58
|
+
|
|
59
|
+
## Fix 1: Undeclared Identifier
|
|
60
|
+
|
|
61
|
+
File: src/service/user.cpp:25
|
|
62
|
+
Error: use of undeclared identifier 'UserRepository'
|
|
63
|
+
Cause: Missing include
|
|
64
|
+
|
|
65
|
+
```cpp
|
|
66
|
+
// Added include
|
|
67
|
+
#include "repository/user_repository.hpp"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
$ cmake --build build
|
|
72
|
+
# 2 errors remaining
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Fix 2: No Matching Function
|
|
76
|
+
|
|
77
|
+
File: src/handler/api.cpp:42
|
|
78
|
+
Error: no matching function for call to 'process'
|
|
79
|
+
|
|
80
|
+
```cpp
|
|
81
|
+
// Changed
|
|
82
|
+
process(params.get("count"));
|
|
83
|
+
// To
|
|
84
|
+
process(std::stoi(params.get("count")));
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
$ cmake --build build
|
|
89
|
+
# 1 error remaining
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Fix 3: Missing Return
|
|
93
|
+
|
|
94
|
+
File: src/handler/api.cpp:58
|
|
95
|
+
Error: non-void function does not return a value
|
|
96
|
+
|
|
97
|
+
```cpp
|
|
98
|
+
std::optional<User> getUser(const std::string& id) {
|
|
99
|
+
if (id.empty()) {
|
|
100
|
+
return std::nullopt;
|
|
101
|
+
}
|
|
102
|
+
auto user = findUser(id);
|
|
103
|
+
// Added missing return
|
|
104
|
+
return user;
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
$ cmake --build build
|
|
110
|
+
# Build successful!
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Final Verification
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
$ ctest --test-dir build --output-on-failure
|
|
117
|
+
Test project build
|
|
118
|
+
1/5 Test #1: unit_tests ........ Passed 0.02 sec
|
|
119
|
+
2/5 Test #2: integration_tests Passed 0.15 sec
|
|
120
|
+
All tests passed.
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Summary
|
|
124
|
+
|
|
125
|
+
| Metric | Count |
|
|
126
|
+
|--------|-------|
|
|
127
|
+
| Build errors fixed | 3 |
|
|
128
|
+
| Linker errors fixed | 0 |
|
|
129
|
+
| Files modified | 2 |
|
|
130
|
+
| Remaining issues | 0 |
|
|
131
|
+
|
|
132
|
+
Build Status: ✅ SUCCESS
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Common Errors Fixed
|
|
136
|
+
|
|
137
|
+
| Error | Typical Fix |
|
|
138
|
+
|-------|-------------|
|
|
139
|
+
| `undeclared identifier` | Add `#include` or fix typo |
|
|
140
|
+
| `no matching function` | Fix argument types or add overload |
|
|
141
|
+
| `undefined reference` | Link library or add implementation |
|
|
142
|
+
| `multiple definition` | Use `inline` or move to .cpp |
|
|
143
|
+
| `incomplete type` | Replace forward decl with `#include` |
|
|
144
|
+
| `no member named X` | Fix member name or include |
|
|
145
|
+
| `cannot convert X to Y` | Add appropriate cast |
|
|
146
|
+
| `CMake Error` | Fix CMakeLists.txt configuration |
|
|
147
|
+
|
|
148
|
+
## Fix Strategy
|
|
149
|
+
|
|
150
|
+
1. **Compilation errors first** - Code must compile
|
|
151
|
+
2. **Linker errors second** - Resolve undefined references
|
|
152
|
+
3. **Warnings third** - Fix with `-Wall -Wextra`
|
|
153
|
+
4. **One fix at a time** - Verify each change
|
|
154
|
+
5. **Minimal changes** - Don't refactor, just fix
|
|
155
|
+
|
|
156
|
+
## Stop Conditions
|
|
157
|
+
|
|
158
|
+
The agent will stop and report if:
|
|
159
|
+
- Same error persists after 3 attempts
|
|
160
|
+
- Fix introduces more errors
|
|
161
|
+
- Requires architectural changes
|
|
162
|
+
- Missing external dependencies
|
|
163
|
+
|
|
164
|
+
## Related Commands
|
|
165
|
+
|
|
166
|
+
- `/cpp-test` - Run tests after build succeeds
|
|
167
|
+
- `/cpp-review` - Review code quality
|
|
168
|
+
- `/verify` - Full verification loop
|
|
169
|
+
|
|
170
|
+
## Related
|
|
171
|
+
|
|
172
|
+
- Agent: `agents/cpp-build-resolver.md`
|
|
173
|
+
- Skill: `skills/cpp-coding-standards/`
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Comprehensive C++ code review for memory safety, modern C++ idioms, concurrency, and security. Invokes the cpp-reviewer agent.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# C++ Code Review
|
|
6
|
+
|
|
7
|
+
This command invokes the **cpp-reviewer** agent for comprehensive C++-specific code review.
|
|
8
|
+
|
|
9
|
+
## What This Command Does
|
|
10
|
+
|
|
11
|
+
1. **Identify C++ Changes**: Find modified `.cpp`, `.hpp`, `.cc`, `.h` files via `git diff`
|
|
12
|
+
2. **Run Static Analysis**: Execute `clang-tidy` and `cppcheck`
|
|
13
|
+
3. **Memory Safety Scan**: Check for raw new/delete, buffer overflows, use-after-free
|
|
14
|
+
4. **Concurrency Review**: Analyze thread safety, mutex usage, data races
|
|
15
|
+
5. **Modern C++ Check**: Verify code follows C++17/20 conventions and best practices
|
|
16
|
+
6. **Generate Report**: Categorize issues by severity
|
|
17
|
+
|
|
18
|
+
## When to Use
|
|
19
|
+
|
|
20
|
+
Use `/cpp-review` when:
|
|
21
|
+
- After writing or modifying C++ code
|
|
22
|
+
- Before committing C++ changes
|
|
23
|
+
- Reviewing pull requests with C++ code
|
|
24
|
+
- Onboarding to a new C++ codebase
|
|
25
|
+
- Checking for memory safety issues
|
|
26
|
+
|
|
27
|
+
## Review Categories
|
|
28
|
+
|
|
29
|
+
### CRITICAL (Must Fix)
|
|
30
|
+
- Raw `new`/`delete` without RAII
|
|
31
|
+
- Buffer overflows and use-after-free
|
|
32
|
+
- Data races without synchronization
|
|
33
|
+
- Command injection via `system()`
|
|
34
|
+
- Uninitialized variable reads
|
|
35
|
+
- Null pointer dereferences
|
|
36
|
+
|
|
37
|
+
### HIGH (Should Fix)
|
|
38
|
+
- Rule of Five violations
|
|
39
|
+
- Missing `std::lock_guard` / `std::scoped_lock`
|
|
40
|
+
- Detached threads without proper lifetime management
|
|
41
|
+
- C-style casts instead of `static_cast`/`dynamic_cast`
|
|
42
|
+
- Missing `const` correctness
|
|
43
|
+
|
|
44
|
+
### MEDIUM (Consider)
|
|
45
|
+
- Unnecessary copies (pass by value instead of `const&`)
|
|
46
|
+
- Missing `reserve()` on known-size containers
|
|
47
|
+
- `using namespace std;` in headers
|
|
48
|
+
- Missing `[[nodiscard]]` on important return values
|
|
49
|
+
- Overly complex template metaprogramming
|
|
50
|
+
|
|
51
|
+
## Automated Checks Run
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Static analysis
|
|
55
|
+
clang-tidy --checks='*,-llvmlibc-*' src/*.cpp -- -std=c++17
|
|
56
|
+
|
|
57
|
+
# Additional analysis
|
|
58
|
+
cppcheck --enable=all --suppress=missingIncludeSystem src/
|
|
59
|
+
|
|
60
|
+
# Build with warnings
|
|
61
|
+
cmake --build build -- -Wall -Wextra -Wpedantic
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Example Usage
|
|
65
|
+
|
|
66
|
+
```text
|
|
67
|
+
User: /cpp-review
|
|
68
|
+
|
|
69
|
+
Agent:
|
|
70
|
+
# C++ Code Review Report
|
|
71
|
+
|
|
72
|
+
## Files Reviewed
|
|
73
|
+
- src/handler/user.cpp (modified)
|
|
74
|
+
- src/service/auth.cpp (modified)
|
|
75
|
+
|
|
76
|
+
## Static Analysis Results
|
|
77
|
+
✓ clang-tidy: 2 warnings
|
|
78
|
+
✓ cppcheck: No issues
|
|
79
|
+
|
|
80
|
+
## Issues Found
|
|
81
|
+
|
|
82
|
+
[CRITICAL] Memory Leak
|
|
83
|
+
File: src/service/auth.cpp:45
|
|
84
|
+
Issue: Raw `new` without matching `delete`
|
|
85
|
+
```cpp
|
|
86
|
+
auto* session = new Session(userId); // Memory leak!
|
|
87
|
+
cache[userId] = session;
|
|
88
|
+
```
|
|
89
|
+
Fix: Use `std::unique_ptr`
|
|
90
|
+
```cpp
|
|
91
|
+
auto session = std::make_unique<Session>(userId);
|
|
92
|
+
cache[userId] = std::move(session);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
[HIGH] Missing const Reference
|
|
96
|
+
File: src/handler/user.cpp:28
|
|
97
|
+
Issue: Large object passed by value
|
|
98
|
+
```cpp
|
|
99
|
+
void processUser(User user) { // Unnecessary copy
|
|
100
|
+
```
|
|
101
|
+
Fix: Pass by const reference
|
|
102
|
+
```cpp
|
|
103
|
+
void processUser(const User& user) {
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Summary
|
|
107
|
+
- CRITICAL: 1
|
|
108
|
+
- HIGH: 1
|
|
109
|
+
- MEDIUM: 0
|
|
110
|
+
|
|
111
|
+
Recommendation: ❌ Block merge until CRITICAL issue is fixed
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Approval Criteria
|
|
115
|
+
|
|
116
|
+
| Status | Condition |
|
|
117
|
+
|--------|-----------|
|
|
118
|
+
| ✅ Approve | No CRITICAL or HIGH issues |
|
|
119
|
+
| ⚠️ Warning | Only MEDIUM issues (merge with caution) |
|
|
120
|
+
| ❌ Block | CRITICAL or HIGH issues found |
|
|
121
|
+
|
|
122
|
+
## Integration with Other Commands
|
|
123
|
+
|
|
124
|
+
- Use `/cpp-test` first to ensure tests pass
|
|
125
|
+
- Use `/cpp-build` if build errors occur
|
|
126
|
+
- Use `/cpp-review` before committing
|
|
127
|
+
- Use `/code-review` for non-C++ specific concerns
|
|
128
|
+
|
|
129
|
+
## Related
|
|
130
|
+
|
|
131
|
+
- Agent: `agents/cpp-reviewer.md`
|
|
132
|
+
- Skills: `skills/cpp-coding-standards/`, `skills/cpp-testing/`
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Enforce TDD workflow for C++. Write GoogleTest tests first, then implement. Verify coverage with gcov/lcov.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# C++ TDD Command
|
|
6
|
+
|
|
7
|
+
This command enforces test-driven development methodology for C++ code using GoogleTest/GoogleMock with CMake/CTest.
|
|
8
|
+
|
|
9
|
+
## What This Command Does
|
|
10
|
+
|
|
11
|
+
1. **Define Interfaces**: Scaffold class/function signatures first
|
|
12
|
+
2. **Write Tests**: Create comprehensive GoogleTest test cases (RED)
|
|
13
|
+
3. **Run Tests**: Verify tests fail for the right reason
|
|
14
|
+
4. **Implement Code**: Write minimal code to pass (GREEN)
|
|
15
|
+
5. **Refactor**: Improve while keeping tests green
|
|
16
|
+
6. **Check Coverage**: Ensure 80%+ coverage
|
|
17
|
+
|
|
18
|
+
## When to Use
|
|
19
|
+
|
|
20
|
+
Use `/cpp-test` when:
|
|
21
|
+
- Implementing new C++ functions or classes
|
|
22
|
+
- Adding test coverage to existing code
|
|
23
|
+
- Fixing bugs (write failing test first)
|
|
24
|
+
- Building critical business logic
|
|
25
|
+
- Learning TDD workflow in C++
|
|
26
|
+
|
|
27
|
+
## TDD Cycle
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
RED → Write failing GoogleTest test
|
|
31
|
+
GREEN → Implement minimal code to pass
|
|
32
|
+
REFACTOR → Improve code, tests stay green
|
|
33
|
+
REPEAT → Next test case
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Example Session
|
|
37
|
+
|
|
38
|
+
````
|
|
39
|
+
User: /cpp-test I need a function to validate email addresses
|
|
40
|
+
|
|
41
|
+
Agent:
|
|
42
|
+
# TDD Session: Email Validator
|
|
43
|
+
|
|
44
|
+
## Step 1: Define Interface
|
|
45
|
+
|
|
46
|
+
```cpp
|
|
47
|
+
// validator/email.hpp
|
|
48
|
+
#pragma once
|
|
49
|
+
#include <string>
|
|
50
|
+
#include <expected>
|
|
51
|
+
|
|
52
|
+
enum class EmailError {
|
|
53
|
+
Empty,
|
|
54
|
+
InvalidFormat
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
std::expected<void, EmailError> validate_email(const std::string& email);
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Step 2: Write Tests (RED)
|
|
61
|
+
|
|
62
|
+
```cpp
|
|
63
|
+
// validator/email_test.cpp
|
|
64
|
+
#include <gtest/gtest.h>
|
|
65
|
+
#include "email.hpp"
|
|
66
|
+
|
|
67
|
+
TEST(ValidateEmail, AcceptsSimpleEmail) {
|
|
68
|
+
auto result = validate_email("user@example.com");
|
|
69
|
+
EXPECT_TRUE(result.has_value());
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
TEST(ValidateEmail, AcceptsSubdomain) {
|
|
73
|
+
EXPECT_TRUE(validate_email("user@mail.example.com").has_value());
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
TEST(ValidateEmail, AcceptsPlus) {
|
|
77
|
+
EXPECT_TRUE(validate_email("user+tag@example.com").has_value());
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
TEST(ValidateEmail, RejectsEmpty) {
|
|
81
|
+
auto result = validate_email("");
|
|
82
|
+
ASSERT_FALSE(result.has_value());
|
|
83
|
+
EXPECT_EQ(result.error(), EmailError::Empty);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
TEST(ValidateEmail, RejectsNoAtSign) {
|
|
87
|
+
EXPECT_FALSE(validate_email("userexample.com").has_value());
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
TEST(ValidateEmail, RejectsNoDomain) {
|
|
91
|
+
EXPECT_FALSE(validate_email("user@").has_value());
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
TEST(ValidateEmail, RejectsNoLocalPart) {
|
|
95
|
+
EXPECT_FALSE(validate_email("@example.com").has_value());
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Step 3: Run Tests - Verify FAIL
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
$ cmake --build build && ctest --test-dir build --output-on-failure
|
|
103
|
+
|
|
104
|
+
1/1 Test #1: email_validator_test .....***Failed
|
|
105
|
+
--- undefined reference to `validate_email`
|
|
106
|
+
|
|
107
|
+
FAIL
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
✓ Tests fail as expected (unimplemented).
|
|
111
|
+
|
|
112
|
+
## Step 4: Implement Minimal Code (GREEN)
|
|
113
|
+
|
|
114
|
+
```cpp
|
|
115
|
+
// validator/email.cpp
|
|
116
|
+
#include "email.hpp"
|
|
117
|
+
#include <regex>
|
|
118
|
+
|
|
119
|
+
std::expected<void, EmailError> validate_email(const std::string& email) {
|
|
120
|
+
if (email.empty()) {
|
|
121
|
+
return std::unexpected(EmailError::Empty);
|
|
122
|
+
}
|
|
123
|
+
static const std::regex pattern(R"([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})");
|
|
124
|
+
if (!std::regex_match(email, pattern)) {
|
|
125
|
+
return std::unexpected(EmailError::InvalidFormat);
|
|
126
|
+
}
|
|
127
|
+
return {};
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Step 5: Run Tests - Verify PASS
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
$ cmake --build build && ctest --test-dir build --output-on-failure
|
|
135
|
+
|
|
136
|
+
1/1 Test #1: email_validator_test ..... Passed 0.01 sec
|
|
137
|
+
|
|
138
|
+
100% tests passed.
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
✓ All tests passing!
|
|
142
|
+
|
|
143
|
+
## Step 6: Check Coverage
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
$ cmake -DCMAKE_CXX_FLAGS="--coverage" -B build && cmake --build build
|
|
147
|
+
$ ctest --test-dir build
|
|
148
|
+
$ lcov --capture --directory build --output-file coverage.info
|
|
149
|
+
$ lcov --list coverage.info
|
|
150
|
+
|
|
151
|
+
validator/email.cpp | 100%
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
✓ Coverage: 100%
|
|
155
|
+
|
|
156
|
+
## TDD Complete!
|
|
157
|
+
````
|
|
158
|
+
|
|
159
|
+
## Test Patterns
|
|
160
|
+
|
|
161
|
+
### Basic Tests
|
|
162
|
+
```cpp
|
|
163
|
+
TEST(SuiteName, TestName) {
|
|
164
|
+
EXPECT_EQ(add(2, 3), 5);
|
|
165
|
+
EXPECT_NE(result, nullptr);
|
|
166
|
+
EXPECT_TRUE(is_valid);
|
|
167
|
+
EXPECT_THROW(func(), std::invalid_argument);
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Fixtures
|
|
172
|
+
```cpp
|
|
173
|
+
class DatabaseTest : public ::testing::Test {
|
|
174
|
+
protected:
|
|
175
|
+
void SetUp() override { db_ = create_test_db(); }
|
|
176
|
+
void TearDown() override { db_.reset(); }
|
|
177
|
+
std::unique_ptr<Database> db_;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
TEST_F(DatabaseTest, InsertsRecord) {
|
|
181
|
+
db_->insert("key", "value");
|
|
182
|
+
EXPECT_EQ(db_->get("key"), "value");
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Parameterized Tests
|
|
187
|
+
```cpp
|
|
188
|
+
class PrimeTest : public ::testing::TestWithParam<std::pair<int, bool>> {};
|
|
189
|
+
|
|
190
|
+
TEST_P(PrimeTest, ChecksPrimality) {
|
|
191
|
+
auto [input, expected] = GetParam();
|
|
192
|
+
EXPECT_EQ(is_prime(input), expected);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
INSTANTIATE_TEST_SUITE_P(Primes, PrimeTest, ::testing::Values(
|
|
196
|
+
std::make_pair(2, true),
|
|
197
|
+
std::make_pair(4, false),
|
|
198
|
+
std::make_pair(7, true)
|
|
199
|
+
));
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Coverage Commands
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
# Build with coverage
|
|
206
|
+
cmake -DCMAKE_CXX_FLAGS="--coverage" -DCMAKE_EXE_LINKER_FLAGS="--coverage" -B build
|
|
207
|
+
|
|
208
|
+
# Run tests
|
|
209
|
+
cmake --build build && ctest --test-dir build
|
|
210
|
+
|
|
211
|
+
# Generate coverage report
|
|
212
|
+
lcov --capture --directory build --output-file coverage.info
|
|
213
|
+
lcov --remove coverage.info '/usr/*' --output-file coverage.info
|
|
214
|
+
genhtml coverage.info --output-directory coverage_html
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Coverage Targets
|
|
218
|
+
|
|
219
|
+
| Code Type | Target |
|
|
220
|
+
|-----------|--------|
|
|
221
|
+
| Critical business logic | 100% |
|
|
222
|
+
| Public APIs | 90%+ |
|
|
223
|
+
| General code | 80%+ |
|
|
224
|
+
| Generated code | Exclude |
|
|
225
|
+
|
|
226
|
+
## TDD Best Practices
|
|
227
|
+
|
|
228
|
+
**DO:**
|
|
229
|
+
- Write test FIRST, before any implementation
|
|
230
|
+
- Run tests after each change
|
|
231
|
+
- Use `EXPECT_*` (continues) over `ASSERT_*` (stops) when appropriate
|
|
232
|
+
- Test behavior, not implementation details
|
|
233
|
+
- Include edge cases (empty, null, max values, boundary conditions)
|
|
234
|
+
|
|
235
|
+
**DON'T:**
|
|
236
|
+
- Write implementation before tests
|
|
237
|
+
- Skip the RED phase
|
|
238
|
+
- Test private methods directly (test through public API)
|
|
239
|
+
- Use `sleep` in tests
|
|
240
|
+
- Ignore flaky tests
|
|
241
|
+
|
|
242
|
+
## Related Commands
|
|
243
|
+
|
|
244
|
+
- `/cpp-build` - Fix build errors
|
|
245
|
+
- `/cpp-review` - Review code after implementation
|
|
246
|
+
- `/verify` - Run full verification loop
|
|
247
|
+
|
|
248
|
+
## Related
|
|
249
|
+
|
|
250
|
+
- Skill: `skills/cpp-testing/`
|
|
251
|
+
- Skill: `skills/tdd-workflow/`
|