@softspark/ai-toolkit 3.0.2 → 3.1.1
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/AGENTS.md +13 -0
- package/CHANGELOG.md +35 -0
- package/README.md +25 -39
- package/app/.claude-plugin/plugin.json +1 -1
- package/app/skills/cpp-rules/SKILL.md +275 -0
- package/app/skills/csharp-rules/SKILL.md +282 -0
- package/app/skills/dart-rules/SKILL.md +299 -0
- package/app/skills/golang-rules/SKILL.md +262 -0
- package/app/skills/java-rules/SKILL.md +273 -0
- package/app/skills/kotlin-rules/SKILL.md +271 -0
- package/app/skills/medplum-rules/SKILL.md +271 -0
- package/app/skills/php-rules/SKILL.md +292 -0
- package/app/skills/python-rules/SKILL.md +257 -0
- package/app/skills/ruby-rules/SKILL.md +286 -0
- package/app/skills/rust-rules/SKILL.md +276 -0
- package/app/skills/swift-rules/SKILL.md +293 -0
- package/app/skills/typescript-rules/SKILL.md +249 -0
- package/benchmarks/ecosystem-doctor-snapshot.json +14 -14
- package/kb/history/completed/deep-coverage-v3-20260423.md +3 -3
- package/kb/history/completed/ecosystem-deep-sweep-20260423.md +1 -1
- package/kb/procedures/release-preparation-sop.md +4 -4
- package/kb/procedures/release-verification-sop.md +11 -12
- package/kb/reference/architecture-overview.md +1 -1
- package/kb/reference/global-install-model.md +29 -6
- package/kb/reference/language-rules.md +54 -18
- package/kb/reference/mcp-editor-compatibility.md +4 -3
- package/kb/reference/mcp-templates.md +3 -2
- package/kb/reference/supported-tools-registry.md +10 -8
- package/llms-full.txt +133 -58
- package/manifest.json +3 -3
- package/package.json +10 -3
- package/scripts/codex_skill_adapter.py +19 -3
- package/scripts/ecosystem_tools.json +7 -7
- package/scripts/generate_cline_rules.py +17 -8
- package/scripts/generate_codex_skills.py +33 -96
- package/scripts/generate_language_rules_skills.py +232 -0
- package/scripts/generate_roo_rules.py +11 -3
- package/scripts/install.py +6 -1
- package/scripts/install_steps/ai_tools.py +154 -51
- package/scripts/install_steps/install_state.py +14 -2
- package/scripts/install_steps/project_registry.py +38 -5
- package/scripts/mcp_editors.py +7 -0
package/AGENTS.md
CHANGED
|
@@ -465,8 +465,11 @@ Skills are invocable commands or auto-loaded knowledge sources:
|
|
|
465
465
|
- **commit**: Create Conventional Commits with pre-commit validation
|
|
466
466
|
- **content-moderation-patterns**: Loaded when user builds content moderation, safety filters, or policy enforcement with Claude. Covers pre-filter vs LLM-classify, category design, confidence thresholds, and human-in-the-loop.
|
|
467
467
|
- **council**: 4-perspective decision evaluation for architecture choices. Use when user wants multi-angle analysis, needs to decide between alternatives, or mentions 'council', 'evaluate decision', 'pros cons'. Codex-adapted: uses native subagents and plan tracking.
|
|
468
|
+
- **cpp-rules**: C++ coding rules from ai-toolkit: coding-style, frameworks, patterns, security, testing. Triggers: .cpp, .cc, .cxx, .hpp, .h, CMakeLists.txt, Makefile, GoogleTest, clang-tidy. Load when writing, reviewing, or editing C++ code.
|
|
468
469
|
- **csharp-patterns**: C# and .NET development patterns: LINQ, async/await, dependency injection, records, nullable reference types, ASP.NET Core minimal APIs, EF Core, MediatR. Triggers: C#, .NET, dotnet, ASP.NET, EF Core, LINQ, IServiceCollection, record type, async C#, nullable reference types. Load when writing or reviewing C#/.NET code.
|
|
470
|
+
- **csharp-rules**: C#/.NET coding rules from ai-toolkit: coding-style, frameworks, patterns, security, testing. Triggers: .cs, .csproj, .sln, ASP.NET, ASP.NET Core, EF Core, LINQ, NUnit, xUnit, dotnet. Load when writing, reviewing, or editing C#/.NET code.
|
|
469
471
|
- **cve-scan**: Scan project dependencies for known CVEs using native audit tools (npm, pip, composer, cargo, go, bundler, dart)
|
|
472
|
+
- **dart-rules**: Dart/Flutter coding rules from ai-toolkit: coding-style, frameworks, patterns, security, testing. Triggers: .dart, pubspec.yaml, Flutter, Riverpod, Bloc, widget, StatelessWidget, StatefulWidget. Load when writing, reviewing, or editing Dart/Flutter code.
|
|
470
473
|
- **database-patterns**: Database schema design and query optimization: normalization, indexing strategies, joins, N+1, transactions, isolation levels, partitioning, EXPLAIN plans. Triggers: schema, table design, index, slow query, N+1, PostgreSQL, MySQL, SQL Server, SQL, EXPLAIN, query plan, transaction, deadlock. Load when designing tables or tuning queries.
|
|
471
474
|
- **debug**: Debug errors and trace root causes systematically using logs, health checks, and hypothesis-driven investigation. Use when a bug or error message is in hand — not for architectural questions or when there is no reproducible symptom.
|
|
472
475
|
- **debugging-tactics**: Root-cause debugging with 4-phase method: investigation, hypothesis, validation, fix. No fix without RCA. Triggers: bug, error, exception, stack trace, not working, intermittent, flaky, crash, regression, fails sometimes, why is X happening, broken after. Load when user reports a bug or asks to investigate failing code.
|
|
@@ -484,6 +487,7 @@ Skills are invocable commands or auto-loaded knowledge sources:
|
|
|
484
487
|
- **fix**: Apply a targeted fix to a known bug or lint error and verify it with the same command that surfaced the problem. Use when the root cause is already identified — not for unknown symptoms or open-ended debugging.
|
|
485
488
|
- **flutter-patterns**: Flutter and Dart development patterns: widget composition, state management (Riverpod/Bloc/Provider), navigation, async, platform channels, performance. Triggers: Flutter, Dart, widget, StatefulWidget, Riverpod, Bloc, Provider, pubspec, Navigator, platform channel, hot reload, StatelessWidget. Load when writing or reviewing Flutter code.
|
|
486
489
|
- **git-mastery**: Advanced Git workflows: interactive rebase, bisect, reflog, cherry-pick, worktrees, history rewriting, submodules, large-file migration (LFS/filter-repo). Triggers: git rebase, bisect, cherry-pick, reflog, force push, history rewrite, detached HEAD, merge conflict, worktree, squash, fixup, submodule. Load when user needs non-trivial Git operations.
|
|
490
|
+
- **golang-rules**: Go coding rules from ai-toolkit: coding-style, frameworks, patterns, security, testing. Triggers: .go, go.mod, go.sum, Gin, Echo, Gorilla, testing, gofmt. Load when writing, reviewing, or editing Go code.
|
|
487
491
|
- **grill-me**: Stress-test a plan or design through relentless Socratic questioning, walking down each decision branch until reaching shared understanding. Use when user wants to stress-test a plan, get grilled, validate assumptions, or mentions 'grill me'. Codex-adapted: uses native subagents and plan tracking.
|
|
488
492
|
- **health**: Report service and infrastructure health status via liveness/readiness checks, resource usage, and quick diagnostics. Use when the user asks whether services are up or degraded — not for deep debugging of a known error.
|
|
489
493
|
- **hipaa-validate**: Validate code against HIPAA policy: PHI exposure, missing audit logging, unencrypted transmission/storage, access control gaps, temp file exposure, and missing BAA references
|
|
@@ -493,11 +497,14 @@ Skills are invocable commands or auto-loaded knowledge sources:
|
|
|
493
497
|
- **instinct-review**: Review, promote, or remove learned instincts extracted from past sessions (`.claude/instincts/*.md`). Use when the user wants to curate the instinct list — not to extract new instincts or edit memory.
|
|
494
498
|
- **introspect**: Agent self-debugging and recovery. Use when stuck in loops, making repeated errors, or quality degrades. Triggers: introspect, self-debug, stuck, loop, why failing.
|
|
495
499
|
- **java-patterns**: Java development patterns: Spring Boot, CompletableFuture, records, sealed types, streams, JPA/Hibernate, Maven/Gradle, virtual threads (Loom). Triggers: Java, Spring, Spring Boot, JPA, Hibernate, Maven, Gradle, CompletableFuture, record type, sealed class, virtual thread. Load when writing or reviewing Java code.
|
|
500
|
+
- **java-rules**: Java coding rules from ai-toolkit: coding-style, frameworks, patterns, security, testing. Triggers: .java, pom.xml, build.gradle, Spring, Spring Boot, JPA, Hibernate, JUnit, Maven, Gradle. Load when writing, reviewing, or editing Java code.
|
|
496
501
|
- **json-mode-patterns**: Loaded when user needs structured JSON output from Claude. Covers tool-use-as-JSON-mode, schema design, parsing, partial recovery, and validation.
|
|
497
502
|
- **kotlin-patterns**: Kotlin development patterns: coroutines, Flow, sealed classes, data classes, extension functions, null safety, Ktor, Jetpack Compose, KMP. Triggers: Kotlin, coroutine, Flow, suspend, Ktor, Android Kotlin, Jetpack Compose, sealed class, data class, KMP, kotlinx. Load when writing or reviewing Kotlin code.
|
|
503
|
+
- **kotlin-rules**: Kotlin coding rules from ai-toolkit: coding-style, frameworks, patterns, security, testing. Triggers: .kt, .kts, build.gradle.kts, Ktor, Jetpack Compose, coroutines, kotlinx. Load when writing, reviewing, or editing Kotlin code.
|
|
498
504
|
- **lint**: Run the project's linter and type-checker with auto-detected toolchain (ruff/mypy, eslint/tsc, phpstan, golangci-lint, clippy, dart analyze). Use when the user asks for static-analysis feedback — not to run tests or refactor.
|
|
499
505
|
- **mcp-builder**: Build production-grade MCP (Model Context Protocol) servers from scratch using the 4-phase methodology: research, implement, test, evaluate. Use when creating new MCP integrations for external APIs, databases, or internal services.
|
|
500
506
|
- **mcp-patterns**: MCP (Model Context Protocol) server design: tool schemas, resource patterns, transport selection (stdio/SSE), client configuration, error handling, capability negotiation. Triggers: MCP, Model Context Protocol, MCP server, MCP tool, MCP resource, JSON-RPC, stdio transport, SSE transport, Claude Desktop config, Cursor MCP. Load when building or integrating MCP servers.
|
|
507
|
+
- **medplum-rules**: Medplum (FHIR healthcare) coding rules from ai-toolkit: coding-style, frameworks, patterns, security, testing. Triggers: medplum.config.mts, medplum.config.ts, FHIR, Medplum, Bot, Subscription, Questionnaire. Load when writing, reviewing, or editing Medplum (FHIR healthcare) code.
|
|
501
508
|
- **mem-search**: Search past coding sessions using natural language. Finds relevant observations, decisions, and context from previous work.
|
|
502
509
|
- **migrate**: Run or create database migrations with the detected tool (Alembic, Prisma, Laravel, Django, Flyway, Drizzle) and verify backups exist first. Use when the user asks to apply, roll back, or generate a migration — not for general schema design.
|
|
503
510
|
- **migration-patterns**: Zero-downtime database migration patterns: expand-contract, double-write, backfill, blue-green schema changes, feature flags, rollback safety, online DDL. Triggers: migration, schema change, zero-downtime, expand-contract, double-write, backfill, ALTER TABLE, column rename, safe deploy, online DDL. Load when planning non-trivial DB schema changes.
|
|
@@ -509,6 +516,7 @@ Skills are invocable commands or auto-loaded knowledge sources:
|
|
|
509
516
|
- **panic**: Emergency kill switch that halts all agent activity via a lockfile gate. Use when agents are looping, misbehaving, or the user wants to stop everything NOW — not for normal workflow interruptions.
|
|
510
517
|
- **performance-profiling**: Performance measurement and optimization: four golden signals (latency/traffic/errors/saturation), p50/p95/p99, baseline-change-measure loop, flame graphs, load testing. Triggers: performance, slow, latency, p99, flame graph, profile, bottleneck, optimization, load test, benchmark, CPU profiling, memory leak. Load when diagnosing or optimizing slow code or services.
|
|
511
518
|
- **persona**: Switch engineering persona at runtime: backend-lead, frontend-lead, devops-eng, junior-dev
|
|
519
|
+
- **php-rules**: PHP coding rules from ai-toolkit: coding-style, frameworks, patterns, security, testing. Triggers: .php, composer.json, Laravel, Symfony, PHPUnit, PSR-12, Composer. Load when writing, reviewing, or editing PHP code.
|
|
512
520
|
- **plan**: Breaks down feature requests and project goals into phased implementation plans with task lists, agent assignments, dependency graphs, and success criteria. Use when the user asks to plan a feature, create an implementation roadmap, break down a coding task, or outline project phases.
|
|
513
521
|
- **plan-writing**: Implementation plan and pre-mortem drafting: phase breakdown, success criteria, risks, rollback plan, acceptance tests, estimated effort. Triggers: implementation plan, pre-mortem, phased plan, project plan, task breakdown, success criteria, rollback strategy, risk register. Load when user asks to write a plan or pre-mortem document.
|
|
514
522
|
- **plugin-creator**: Creates experimental opt-in plugin packs with manifests, conventions, and optional module scaffolding for Claude and Codex runtimes
|
|
@@ -517,6 +525,7 @@ Skills are invocable commands or auto-loaded knowledge sources:
|
|
|
517
525
|
- **prd-to-plan**: Convert a PRD into a phased implementation plan using tracer-bullet vertical slices. Use when user wants to break down a PRD, create an implementation plan, plan phases from a PRD, or mentions tracer bullets. Codex-adapted: uses native subagents and plan tracking.
|
|
518
526
|
- **predict**: Analyzes code diffs and file changes to identify potential regressions, maps dependency impact across the codebase, and generates a risk-scored impact report. Use when reviewing pull requests, assessing code change risk, checking for breaking changes, or analyzing the blast radius of a diff.
|
|
519
527
|
- **prompt-caching-patterns**: Loaded when user builds with Anthropic API and needs to cut cost or latency via prompt caching. Covers TTL, cache breakpoints, stacking, invalidation, and measuring hit rate.
|
|
528
|
+
- **python-rules**: Python coding rules from ai-toolkit: coding-style, frameworks, patterns, security, testing. Triggers: .py, .pyi, pyproject.toml, requirements.txt, Pipfile, FastAPI, Django, Flask, pytest, SQLAlchemy, ruff, mypy. Load when writing, reviewing, or editing Python code.
|
|
520
529
|
- **qa-session**: Interactive QA session where user reports bugs conversationally and agent files GitHub issues with domain language. Explores codebase in background for context. Use when user wants to report bugs, do QA, file issues conversationally, or mentions QA session. Codex-adapted: uses native subagents and plan tracking.
|
|
521
530
|
- **rag-patterns**: RAG architecture: embeddings, chunking strategies, hybrid search (BM25 + vector), reranking, CRAG/self-correcting, multi-hop reasoning, evaluation metrics. Triggers: RAG, embedding, vector search, pgvector, Qdrant, Pinecone, Weaviate, chunking, reranker, retrieval, hybrid search, semantic search, knowledge base, cosine similarity. Load when building or tuning RAG systems.
|
|
522
531
|
- **refactor**: Refactor code for quality and maintainability
|
|
@@ -526,7 +535,9 @@ Skills are invocable commands or auto-loaded knowledge sources:
|
|
|
526
535
|
- **review**: Review code for quality, security, and correctness
|
|
527
536
|
- **rollback**: Roll back a git commit, database migration, or deployment to a previous known-good state with safety checks and health verification. Use when the user wants to revert recent changes safely — not to undo local edits or halt the whole system.
|
|
528
537
|
- **ruby-patterns**: Ruby and Rails development patterns: blocks, metaprogramming, ActiveRecord, Sidekiq, RSpec, Sorbet/RBS, Hanami, Roda, Rack middleware. Triggers: Ruby, Rails, ActiveRecord, Sidekiq, RSpec, gem, Gemfile, bundler, rake, Hanami, Sorbet. Load when writing or reviewing Ruby code.
|
|
538
|
+
- **ruby-rules**: Ruby coding rules from ai-toolkit: coding-style, frameworks, patterns, security, testing. Triggers: .rb, Gemfile, .gemspec, Rails, ActiveRecord, Sidekiq, RSpec, Sorbet, rubocop. Load when writing, reviewing, or editing Ruby code.
|
|
529
539
|
- **rust-patterns**: Rust development patterns: ownership, borrowing, lifetimes, async (Tokio), error handling (Result/anyhow/thiserror), traits, macros, zero-cost abstractions, unsafe boundaries. Triggers: Rust, borrow checker, lifetime, Tokio, async Rust, cargo, trait, impl, Result, unsafe, lifetime annotation, clippy. Load when writing or reviewing Rust code.
|
|
540
|
+
- **rust-rules**: Rust coding rules from ai-toolkit: coding-style, frameworks, patterns, security, testing. Triggers: .rs, Cargo.toml, Cargo.lock, Tokio, Axum, Serde, clippy, cargo test. Load when writing, reviewing, or editing Rust code.
|
|
530
541
|
- **search**: Search the knowledge base with semantic and hybrid modes
|
|
531
542
|
- **security-patterns**: Application security: OWASP Top 10, authN/authZ, input validation, secrets management, TLS, CSRF/XSS/SQLi, session handling, JWT, rate limiting, CSP. Triggers: security, OWASP, auth, JWT, CSRF, XSS, SQL injection, secrets, encryption, TLS, authentication, authorization, CSP, CORS, password hashing. Load when touching auth code, handling user input, or doing security review.
|
|
532
543
|
- **seo-validate**: Validate code against SEO best practices: W3C semantics, meta/OG tags, Schema.org, hreflang, Core Web Vitals (LCP/INP/CLS), resource hints, GEO, SPA/SSG/CSR crawlability, technical SEO, accessibility-for-SEO. Supports React/Next/Nuxt/Astro/Gatsby/SvelteKit/Remix/Angular/Vue/static HTML.
|
|
@@ -535,12 +546,14 @@ Skills are invocable commands or auto-loaded knowledge sources:
|
|
|
535
546
|
- **subagent-development**: Execute implementation plans using fresh subagents per task with two-stage review: spec compliance first, then code quality. Use when executing plans with independent tasks. Codex-adapted: uses native subagents and plan tracking.
|
|
536
547
|
- **swarm**: Execute tasks via Map-Reduce, Consensus, or Relay swarms Codex-adapted: uses native subagents and plan tracking.
|
|
537
548
|
- **swift-patterns**: Swift and iOS development patterns: SwiftUI, Combine, async/await, property wrappers, actors, Swift Package Manager, Core Data, UIKit interop, @MainActor. Triggers: Swift, SwiftUI, Combine, iOS, Xcode, actor, property wrapper, Core Data, SPM, UIKit, @MainActor, @State, @Binding. Load when writing or reviewing Swift code.
|
|
549
|
+
- **swift-rules**: Swift coding rules from ai-toolkit: coding-style, frameworks, patterns, security, testing. Triggers: .swift, Package.swift, .xcodeproj, SwiftUI, Combine, async/await, XCTest. Load when writing, reviewing, or editing Swift code.
|
|
538
550
|
- **tdd**: Test-driven development with red-green-refactor loop and vertical slices. Use when user wants TDD, test-first development, red-green-refactor, or building features with tests driving the implementation. Codex-adapted: uses native subagents and plan tracking.
|
|
539
551
|
- **teams**: Launches pre-configured multi-agent teams for code review, debugging, feature development, security audits, and database migrations. Use when the user asks to start a multi-agent workflow, coordinate agent teams, run a team review, or needs parallel agent collaboration on a complex task. Codex-adapted: uses native subagents and plan tracking.
|
|
540
552
|
- **test**: Run the project's test suite with coverage reporting, auto-detecting the framework (pytest, vitest, jest, flutter test, go test, cargo test, phpunit). Use when the user asks to run existing tests — not to author new ones test-first.
|
|
541
553
|
- **testing-patterns**: Testing strategy and craft: pyramid vs trophy, unit/integration/e2e split, fixtures, mocks vs fakes vs stubs, AAA pattern, flaky test diagnosis, coverage goals, property-based testing. Triggers: test, testing strategy, fixture, mock, stub, AAA, unit test, integration test, e2e, Playwright, Cypress, flaky, coverage, TDD, test pyramid. Load when writing, reviewing, or designing test suites.
|
|
542
554
|
- **triage-issue**: Triage a bug by deeply exploring the codebase for root cause, then create a GitHub issue with a TDD-based fix plan. Mostly hands-off — minimal user interaction. Use when user reports a bug, wants to investigate an issue, mentions triage, or wants a fix plan. Codex-adapted: uses native subagents and plan tracking.
|
|
543
555
|
- **typescript-patterns**: TypeScript type safety patterns: strict mode, generics, conditional types, template literals, discriminated unions, branded types, Zod, satisfies operator, const assertions. Triggers: TypeScript, TS, generics, conditional type, utility type, strict, Zod, satisfies, discriminated union, type safety, type narrowing, template literal type. Load when writing or reviewing TypeScript code.
|
|
556
|
+
- **typescript-rules**: TypeScript/JavaScript coding rules from ai-toolkit: coding-style, frameworks, patterns, security, testing. Triggers: .ts, .tsx, .js, .jsx, package.json, tsconfig.json, React, Next.js, Vue, Vite, Vitest, Jest, ESLint. Load when writing, reviewing, or editing TypeScript/JavaScript code.
|
|
544
557
|
- **ubiquitous-language**: Extract a DDD-style ubiquitous language glossary from the conversation, flagging ambiguities and proposing canonical terms. Saves to UBIQUITOUS_LANGUAGE.md. Use when user wants to define domain terms, build a glossary, harden terminology, or mentions DDD or domain model.
|
|
545
558
|
- **verification-before-completion**: Loaded when agent is about to claim work is complete, fixed, or passing — requires running verification commands and confirming output before making any success claims. Evidence before assertions, always.
|
|
546
559
|
- **workflow**: Start and manage autonomous agent workflows Codex-adapted: uses native subagents and plan tracking.
|
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,41 @@ Versioning follows [Semantic Versioning](https://semver.org/).
|
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
+
## v3.1.1 — Windows install fix (2026-04-29)
|
|
11
|
+
|
|
12
|
+
Patch release. `ai-toolkit install --local` crashed on Windows before doing any work because `scripts/install_steps/project_registry.py` imported `fcntl` (POSIX-only) at module load, raising `ModuleNotFoundError: No module named 'fcntl'`.
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- **Windows install crash** — `project_registry` now imports `fcntl` and `msvcrt` defensively (try/except → `None`) and `_registry_lock()` selects between `fcntl.flock` (POSIX) and `msvcrt.locking` (Windows) at runtime. POSIX semantics unchanged; Windows acquires the lock with `LK_NBLCK` + 30 s deadline + 10 ms retry backoff.
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- **Windows compat regression test** — `tests/test_windows_support.bats` now blocks `import fcntl` via a custom `meta_path` finder, stubs `msvcrt`, and forces the Windows branch of `_registry_lock` so future regressions are caught on the POSIX CI runners without needing a Windows machine.
|
|
21
|
+
|
|
22
|
+
## v3.1.0 — Global Editor Install Alignment (2026-04-28)
|
|
23
|
+
|
|
24
|
+
Minor release aligning global and project-local editor configuration with the current documented surfaces for all supported editors.
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- **Global Cline rules** — `ai-toolkit install --editors cline` now writes documented global rules under `~/Documents/Cline/Rules/ai-toolkit-*.md`.
|
|
29
|
+
- **Global Roo Code rules** — `ai-toolkit install --editors roo` now writes documented global rules under `~/.roo/rules/ai-toolkit-*.md`.
|
|
30
|
+
- **Safe global Aider bootstrap** — `ai-toolkit install --editors aider` now creates `~/.aider.conf.yml` only when absent and refreshes `~/.aider-ai-toolkit-CONVENTIONS.md`; existing user YAML is preserved.
|
|
31
|
+
- **Project Roo MCP sync** — `ai-toolkit mcp install --editor roo --scope project ...` and `install --local --editors roo` now mirror canonical `.mcp.json` servers into `.roo/mcp.json`.
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
|
|
35
|
+
- **Global editor target policy** — global install now uses only documented, file-based targets: `aider`, `augment`, `cline`, `codex`, `gemini`, `opencode`, `roo`, and `windsurf`.
|
|
36
|
+
- **Cursor rules scope** — Cursor rule generation is now explicitly project-local. Cursor still supports project/global MCP via `.cursor/mcp.json` and `~/.cursor/mcp.json`, but global rule writes are not emitted because Cursor's global user rules are settings-managed rather than a stable merge-safe file.
|
|
37
|
+
- **Release and registry docs** — updated the supported-tools registry, MCP compatibility tables, global install model, release SOP, README platform matrix, and ecosystem doctor snapshot for the April 28, 2026 upstream baseline.
|
|
38
|
+
- **Release SOP meta-generator gate** — registry/generator drift checks now exclude `generate_language_rules_skills.py` alongside docs/index meta-generators, keeping the editor registry focused on editor config generators.
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
|
|
42
|
+
- **SOP compliance gap** — Cline, Roo Code, and Aider global surfaces are now used where documented, while Cursor/Copilot/Antigravity rules remain local-only where no safe global rule file exists.
|
|
43
|
+
- **Release metadata drift** — test count is now synced to 973 across README and validation metadata.
|
|
44
|
+
|
|
10
45
|
## v3.0.2 — Validation, Windows, Telemetry, and generate:all parity (2026-04-24)
|
|
11
46
|
|
|
12
47
|
Patch release that closes known validation gaps, expands the hook-surface contracts, adds Windows dependency hints, exposes local product telemetry, and restores `npm run generate:all` parity with the CLI so registered custom rules reach every editor.
|
package/README.md
CHANGED
|
@@ -1,42 +1,25 @@
|
|
|
1
1
|
# ai-toolkit
|
|
2
2
|
|
|
3
|
-
> Professional-grade AI coding toolkit with multi-platform support. Machine-enforced safety,
|
|
3
|
+
> Professional-grade AI coding toolkit with multi-platform support. Machine-enforced safety, 112 skills, 44 agents, expanded lifecycle hooks, persona presets, experimental opt-in plugin packs, and benchmark tooling — works with Claude, Cursor, Windsurf, Copilot, Gemini, Cline, Roo Code, Aider, Augment, Google Antigravity, Codex CLI, and opencode, ready in 60 seconds.
|
|
4
4
|
|
|
5
5
|
[](https://github.com/softspark/ai-toolkit/actions/workflows/ci.yml)
|
|
6
6
|
[](LICENSE)
|
|
7
|
-
[](app/skills/)
|
|
8
8
|
[](app/agents/)
|
|
9
|
-
[](tests/)
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
**3.0.2 is a patch release** that closes known validation gaps, expands the validated hook surface, adds Windows dependency hints, exposes local product telemetry, and restores `npm run generate:all` parity with the CLI.
|
|
16
|
-
|
|
17
|
-
- `validate.py` now checks hook handler types, required handler fields, prompt/agent event compatibility, and structured language-rule frontmatter/category coverage.
|
|
18
|
-
- Hook docs and validation now cover `PostToolUseFailure`, `PostToolBatch`, `UserPromptExpansion`, plus `command`, `http`, `prompt`, `agent`, and `mcp_tool` handler types.
|
|
19
|
-
- `ai-toolkit stats --summary` reports local product telemetry: total invocations, unique skills used, catalog coverage, unused skills, recent activity, and top skills.
|
|
20
|
-
- Windows dependency detection now emits package hints for `winget`, Chocolatey, and Scoop; WSL remains the recommended runtime for Bash hooks.
|
|
21
|
-
- `npm run generate:all` now invokes every directory-based rule generator, so registered custom rules in `~/.softspark/ai-toolkit/rules/` propagate to every editor that supports per-rule module files.
|
|
11
|
+
<p align="center">
|
|
12
|
+
<img src="assets/ai-toolkit-readme-hero.png" alt="ai-toolkit 3 README hero showing one toolkit for 12 AI editors" width="900">
|
|
13
|
+
</p>
|
|
22
14
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
- **Deep coverage: every editor at 100% of its native surface.** New generators emit hooks, sub-agents, custom commands, and skill pointers per editor: `generate_cursor_agents.py`, `generate_cursor_hooks.py`, `generate_windsurf_hooks.py`, `generate_gemini_commands.py`, `generate_gemini_hooks.py`, `generate_gemini_skills.py`, `generate_augment_agents.py`, `generate_augment_commands.py`, `generate_augment_hooks.py`, `generate_augment_skills.py`, `generate_codex_skills.py`.
|
|
26
|
-
- **`--profile full`** turns on every native surface across all supported editors in one flag. `minimal` / `standard` / `strict` retain prior semantics but `standard` now also wires Gemini hooks and the Copilot directory layout (see Breaking Changes).
|
|
27
|
-
- **Opt-in Codex skill mirroring** via `--codex-skills`. Codex gets the full skill catalog materialized under `.agents/skills/`; other editors stay on pointer-skill or compat-read.
|
|
28
|
-
- **58 new bats tests** covering native surface generators plus per-editor suites for aider, antigravity, augment, claude-code, cline, codex, copilot, cursor, gemini, opencode, roo, windsurf.
|
|
29
|
-
- **Skill quality pass** (folded in from the 2.12 work that is now skipped): 62 skills upgraded to 4-5 / 5 on the meta-architect audit; `add_gotcha` added as a fifth mutation strategy.
|
|
30
|
-
|
|
31
|
-
### Breaking changes (from 3.0.0)
|
|
15
|
+
---
|
|
32
16
|
|
|
33
|
-
|
|
34
|
-
- Copilot now uses the **directory layout** (`.github/copilot/`) instead of a single monolithic file. Existing single-file installs are preserved but new installs emit the directory form.
|
|
35
|
-
- `2.13.0` is skipped. Upgrade path is `2.12.x` → `3.0.0`.
|
|
17
|
+
## What's New in v3.1.1
|
|
36
18
|
|
|
37
|
-
|
|
19
|
+
Patch release fixing the Windows install crash introduced when project registration started using a POSIX-only file lock.
|
|
38
20
|
|
|
39
|
-
-
|
|
21
|
+
- **Windows install no longer crashes** — `ai-toolkit install --local` on Windows hit `ModuleNotFoundError: No module named 'fcntl'` before doing any work. The project registry now selects `fcntl` (POSIX) or `msvcrt.locking` (Windows) at runtime; POSIX semantics are unchanged.
|
|
22
|
+
- **Regression test on POSIX CI** — `tests/test_windows_support.bats` simulates the missing-`fcntl` scenario and exercises the Windows lock branch via a stubbed `msvcrt`, so this regression is caught without a Windows runner.
|
|
40
23
|
|
|
41
24
|
See [CHANGELOG.md](CHANGELOG.md) for full history.
|
|
42
25
|
|
|
@@ -53,6 +36,9 @@ See [CHANGELOG.md](CHANGELOG.md) for full history.
|
|
|
53
36
|
- [Getting Started](#getting-started)
|
|
54
37
|
- [Documentation](#documentation)
|
|
55
38
|
- [Contributing](#contributing)
|
|
39
|
+
- [Security](#security)
|
|
40
|
+
- [License](#license)
|
|
41
|
+
- [Changelog](#changelog)
|
|
56
42
|
|
|
57
43
|
---
|
|
58
44
|
|
|
@@ -67,7 +53,7 @@ ai-toolkit install
|
|
|
67
53
|
npx @softspark/ai-toolkit install
|
|
68
54
|
```
|
|
69
55
|
|
|
70
|
-
**That's it.** Claude Code picks up
|
|
56
|
+
**That's it.** Claude Code picks up 112 skills, 44 agents, quality hooks, and the safety constitution automatically.
|
|
71
57
|
|
|
72
58
|
**Windows:** WSL is the recommended runtime. Native Windows works when Git Bash is available for hook scripts; dependency hints cover `winget`, Chocolatey, and Scoop. See [Windows Support](kb/reference/windows-support.md).
|
|
73
59
|
|
|
@@ -119,14 +105,14 @@ See [CLI Reference](kb/reference/cli-reference.md) for all commands and options.
|
|
|
119
105
|
| Platform | Config Files | Scope |
|
|
120
106
|
|----------|-------------|-------|
|
|
121
107
|
| Claude Code | `~/.claude/` | global |
|
|
122
|
-
| Cursor |
|
|
108
|
+
| Cursor | `.cursor/rules/*.mdc` + `.cursor/mcp.json` | project (`~/.cursor/mcp.json` for MCP only) |
|
|
123
109
|
| Windsurf | `~/.codeium/.../global_rules.md` + `.windsurf/rules/*.md` | global + project |
|
|
124
110
|
| Gemini CLI | `~/.gemini/GEMINI.md` | global |
|
|
125
111
|
| GitHub Copilot | `.github/copilot-instructions.md` | project |
|
|
126
|
-
| Cline | `.clinerules/*.md` | project |
|
|
127
|
-
| Roo Code | `.roomodes` + `.roo/rules/*.md` | project |
|
|
128
|
-
| Aider | `.aider.conf.yml` + `CONVENTIONS.md` | project |
|
|
129
|
-
| Augment | `.augment/rules/ai-toolkit-*.md` | project |
|
|
112
|
+
| Cline | `~/Documents/Cline/Rules/*.md` + `.clinerules/*.md` | global + project |
|
|
113
|
+
| Roo Code | `~/.roo/rules/*.md` + `.roomodes` + `.roo/rules/*.md` | global rules + project |
|
|
114
|
+
| Aider | `~/.aider.conf.yml` + `.aider.conf.yml` + `CONVENTIONS.md` | global + project |
|
|
115
|
+
| Augment | `~/.augment/rules/*.md` + `.augment/rules/ai-toolkit-*.md` | global + project |
|
|
130
116
|
| Google Antigravity | `.agent/rules/*.md` + `.agent/workflows/*.md` | project |
|
|
131
117
|
| Codex CLI | `AGENTS.md` + `.agents/rules/*.md` + `.agents/skills/*` + `.codex/hooks.json` | project + global plugin |
|
|
132
118
|
| opencode | `AGENTS.md` + `.opencode/{agents,commands,plugins}/*` + `opencode.json` | project + global (`~/.config/opencode/`) |
|
|
@@ -141,7 +127,7 @@ See [CLI Reference](kb/reference/cli-reference.md) for all commands and options.
|
|
|
141
127
|
|-----------|-------|-------------|
|
|
142
128
|
| `skills/` (task) | 32 | Slash commands: `/commit`, `/build`, `/deploy`, `/test`, `/mcp-builder`, ... |
|
|
143
129
|
| `skills/` (hybrid) | 31 | Slash commands with agent knowledge base |
|
|
144
|
-
| `skills/` (knowledge) |
|
|
130
|
+
| `skills/` (knowledge) | 49 | Domain knowledge auto-loaded by agents (includes 13 `<lang>-rules` skills) |
|
|
145
131
|
| `agents/` | 44 | Specialized agents across 10 categories |
|
|
146
132
|
| `hooks/` | 21 global + 5 skill-scoped | Quality gates, path safety, prompt governance, session lifecycle |
|
|
147
133
|
| `plugins/` | 11 packs | Opt-in domain bundles (security, research, frontend, enterprise, 6 language packs) |
|
|
@@ -157,7 +143,7 @@ See [CLI Reference](kb/reference/cli-reference.md) for all commands and options.
|
|
|
157
143
|
ai-toolkit/
|
|
158
144
|
├── app/
|
|
159
145
|
│ ├── agents/ # 44 agent definitions
|
|
160
|
-
│ ├── skills/ #
|
|
146
|
+
│ ├── skills/ # 112 skills (task / hybrid / knowledge)
|
|
161
147
|
│ ├── rules/ # Auto-injected into your CLAUDE.md
|
|
162
148
|
│ ├── hooks/ # Hook scripts (21 entries, 12 lifecycle events)
|
|
163
149
|
│ ├── plugins/ # 11 experimental plugin packs (opt-in)
|
|
@@ -166,7 +152,7 @@ ai-toolkit/
|
|
|
166
152
|
│ └── ARCHITECTURE.md # Full system design
|
|
167
153
|
├── kb/ # Reference docs, procedures, plans
|
|
168
154
|
├── scripts/ # Validation, install, evaluation scripts
|
|
169
|
-
├── tests/ # Bats test suite (
|
|
155
|
+
├── tests/ # Bats test suite (974 tests)
|
|
170
156
|
└── CHANGELOG.md
|
|
171
157
|
```
|
|
172
158
|
|
|
@@ -176,7 +162,7 @@ ai-toolkit/
|
|
|
176
162
|
|
|
177
163
|
## Key Features
|
|
178
164
|
|
|
179
|
-
**Machine-enforced constitution** —
|
|
165
|
+
**Machine-enforced constitution** — 6-article safety constitution enforced via `PreToolUse` hooks that actually block `rm -rf`, `DROP TABLE`, and irreversible operations. Not just documentation.
|
|
180
166
|
|
|
181
167
|
**21 lifecycle hooks** — Executable scripts across 12 events (SessionStart → SessionEnd). Guards, governance, quality gates, session persistence, MCP health checks. See [Hooks Catalog](kb/reference/hooks-catalog.md).
|
|
182
168
|
|
|
@@ -198,7 +184,7 @@ ai-toolkit/
|
|
|
198
184
|
|
|
199
185
|
**Config inheritance** — Enterprise `extends` system with constitution immutability and enforcement constraints. See [Enterprise Config Guide](kb/reference/enterprise-config-guide.md).
|
|
200
186
|
|
|
201
|
-
**
|
|
187
|
+
**70 language rules** — 13 languages + common, 5 categories each. Auto-detected or explicit `--lang`. See [Language Rules](kb/reference/language-rules.md).
|
|
202
188
|
|
|
203
189
|
**26 MCP templates** — Ready-to-use configs for GitHub, PostgreSQL, Slack, Jira, Sentry, and more. See [MCP Templates](kb/reference/mcp-templates.md).
|
|
204
190
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-toolkit",
|
|
3
3
|
"description": "Professional-grade Claude Code toolkit with persona presets, skill security auditor, expanded lifecycle hooks, experimental opt-in plugin packs, benchmark harvesting, and multi-tool support.",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.1.1",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "SoftSpark",
|
|
7
7
|
"url": "https://github.com/softspark"
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cpp-rules
|
|
3
|
+
description: "C++ coding rules from ai-toolkit: coding-style, frameworks, patterns, security, testing. Triggers: .cpp, .cc, .cxx, .hpp, .h, CMakeLists.txt, Makefile, GoogleTest, clang-tidy. Load when writing, reviewing, or editing C++ code."
|
|
4
|
+
effort: medium
|
|
5
|
+
user-invocable: false
|
|
6
|
+
allowed-tools: Read
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# C++ Rules
|
|
10
|
+
|
|
11
|
+
These rules come from `app/rules/cpp/` in ai-toolkit. They cover
|
|
12
|
+
the project's standards for coding style, frameworks, patterns,
|
|
13
|
+
security, and testing in C++. Apply them when writing or
|
|
14
|
+
reviewing C++ code.
|
|
15
|
+
|
|
16
|
+
# C++ Coding Style
|
|
17
|
+
|
|
18
|
+
## Naming
|
|
19
|
+
- PascalCase: classes, structs, enums, type aliases, concepts.
|
|
20
|
+
- camelCase or snake_case: functions, methods, variables (be consistent per project).
|
|
21
|
+
- UPPER_SNAKE: macros, compile-time constants.
|
|
22
|
+
- Prefix member variables with `m_` or suffix with `_` (pick one convention).
|
|
23
|
+
- Namespace names: lowercase, short (`namespace io`, `namespace util`).
|
|
24
|
+
|
|
25
|
+
## Modern C++ (17/20/23)
|
|
26
|
+
- Use `auto` for iterator types and complex template deductions.
|
|
27
|
+
- Use `std::optional<T>` instead of sentinel values or pointers for optional returns.
|
|
28
|
+
- Use `std::variant` over union types. Use `std::visit` for dispatch.
|
|
29
|
+
- Use `std::string_view` for non-owning string parameters.
|
|
30
|
+
- Use structured bindings: `auto [key, value] = *map.begin();`.
|
|
31
|
+
- Use `constexpr` for compile-time evaluation. Prefer over macros.
|
|
32
|
+
|
|
33
|
+
## Memory Management
|
|
34
|
+
- Use RAII exclusively. Every resource acquisition is an initialization.
|
|
35
|
+
- Use `std::unique_ptr` for exclusive ownership (default choice).
|
|
36
|
+
- Use `std::shared_ptr` only when ownership is genuinely shared.
|
|
37
|
+
- Never use raw `new`/`delete`. Use `std::make_unique` / `std::make_shared`.
|
|
38
|
+
- Use `std::span<T>` (C++20) for non-owning views over contiguous data.
|
|
39
|
+
|
|
40
|
+
## Functions
|
|
41
|
+
- Pass small types by value. Pass large types by `const&`.
|
|
42
|
+
- Use `[[nodiscard]]` on functions whose return value must not be ignored.
|
|
43
|
+
- Use `noexcept` on functions that do not throw (move constructors, destructors).
|
|
44
|
+
- Limit function parameters to 4. Use structs for configuration objects.
|
|
45
|
+
- Use trailing return types for complex template return deductions.
|
|
46
|
+
|
|
47
|
+
## Includes and Dependencies
|
|
48
|
+
- Use `#pragma once` or include guards. Prefer `#pragma once` for simplicity.
|
|
49
|
+
- Order: corresponding header, C++ stdlib, third-party, project headers.
|
|
50
|
+
- Forward-declare in headers when possible to reduce compile times.
|
|
51
|
+
- Minimize header dependencies. Use the Pimpl idiom for ABI stability.
|
|
52
|
+
|
|
53
|
+
## Avoid
|
|
54
|
+
- Raw pointers for ownership. Use smart pointers.
|
|
55
|
+
- C-style casts. Use `static_cast`, `dynamic_cast`, `const_cast`.
|
|
56
|
+
- Macros for constants or functions. Use `constexpr` and templates.
|
|
57
|
+
- `using namespace std;` in headers. Acceptable in .cpp files with caution.
|
|
58
|
+
- `std::endl` -- use `'\n'` (endl flushes the buffer unnecessarily).
|
|
59
|
+
|
|
60
|
+
## Formatting
|
|
61
|
+
- Use clang-format with a committed `.clang-format` file.
|
|
62
|
+
- Use clang-tidy for static analysis and automated modernization.
|
|
63
|
+
- Max line length: 100-120 characters.
|
|
64
|
+
- Braces: use Allman or K&R consistently per project.
|
|
65
|
+
|
|
66
|
+
# C++ Frameworks
|
|
67
|
+
|
|
68
|
+
## CMake
|
|
69
|
+
- Use modern CMake (3.14+): target-based, not directory-based.
|
|
70
|
+
- Use `target_link_libraries` with `PUBLIC`/`PRIVATE`/`INTERFACE` visibility.
|
|
71
|
+
- Use `FetchContent` for dependency management. Avoid manual submodule vendoring.
|
|
72
|
+
- Set `CMAKE_CXX_STANDARD 20` (or 23) at the project level.
|
|
73
|
+
- Use `target_compile_options` for per-target flags, not global `add_compile_options`.
|
|
74
|
+
- Export targets with `install(TARGETS ... EXPORT ...)` for library consumers.
|
|
75
|
+
|
|
76
|
+
## Boost
|
|
77
|
+
- Use Boost.Asio for async networking and I/O.
|
|
78
|
+
- Use `boost::beast` for HTTP/WebSocket built on Asio.
|
|
79
|
+
- Use `boost::json` or `nlohmann/json` for JSON parsing.
|
|
80
|
+
- Prefer C++ stdlib equivalents when available (e.g., `std::optional` over `boost::optional`).
|
|
81
|
+
- Link only the Boost libraries you actually use. Many are header-only.
|
|
82
|
+
|
|
83
|
+
## Qt
|
|
84
|
+
- Use signals and slots for event-driven communication.
|
|
85
|
+
- Use `QObject` parent-child ownership for automatic memory management.
|
|
86
|
+
- Use `QML` for declarative UI. Keep business logic in C++ backend.
|
|
87
|
+
- Use `QThread` with worker objects (moveToThread), not subclassing QThread.
|
|
88
|
+
- Use smart pointers for non-QObject resources. QObject children are auto-deleted.
|
|
89
|
+
|
|
90
|
+
## gRPC
|
|
91
|
+
- Define services in `.proto` files. Generate C++ stubs with `protoc`.
|
|
92
|
+
- Use async server with `CompletionQueue` for high-throughput services.
|
|
93
|
+
- Use `grpc::ClientContext` for per-call deadlines and metadata.
|
|
94
|
+
- Use interceptors for logging, auth, and metrics.
|
|
95
|
+
- Set deadlines on every RPC call to prevent hanging.
|
|
96
|
+
|
|
97
|
+
## Networking (Asio)
|
|
98
|
+
- Use `io_context` as the event loop. Run from one or more threads.
|
|
99
|
+
- Use `co_await` (C++20 coroutines) with Asio for clean async code.
|
|
100
|
+
- Use `strand` for serializing access to shared state across handlers.
|
|
101
|
+
- Use `steady_timer` for timeouts and periodic tasks.
|
|
102
|
+
- Handle errors via `error_code` parameter, not exceptions, in async callbacks.
|
|
103
|
+
|
|
104
|
+
## Database
|
|
105
|
+
- Use `libpq` (PostgreSQL) or `SOCI` for database access.
|
|
106
|
+
- Use prepared statements exclusively. Never concatenate SQL strings.
|
|
107
|
+
- Use connection pooling for multi-threaded server applications.
|
|
108
|
+
- Use `SQLite` via `sqlite3` C API with RAII wrappers for embedded use cases.
|
|
109
|
+
|
|
110
|
+
## Package Management
|
|
111
|
+
- Use `vcpkg` or `Conan 2` for dependency management.
|
|
112
|
+
- Pin dependency versions in `vcpkg.json` or `conanfile.py`.
|
|
113
|
+
- Use CI caching for build artifacts and dependency downloads.
|
|
114
|
+
- Prefer pre-built binary packages for CI speed.
|
|
115
|
+
|
|
116
|
+
# C++ Patterns
|
|
117
|
+
|
|
118
|
+
## Error Handling
|
|
119
|
+
- Use exceptions for truly exceptional conditions. Use return types for expected failures.
|
|
120
|
+
- Use `std::expected<T, E>` (C++23) or `Result<T, E>` pattern for recoverable errors.
|
|
121
|
+
- Use `std::error_code` / `std::error_category` for system-level errors.
|
|
122
|
+
- Use `noexcept` on functions that must not throw (destructors, move operations).
|
|
123
|
+
- Catch by `const&`. Never catch by value (slicing) or pointer.
|
|
124
|
+
|
|
125
|
+
## RAII Patterns
|
|
126
|
+
- Wrap every resource (memory, file, lock, socket) in an RAII type.
|
|
127
|
+
- Use `std::lock_guard` or `std::scoped_lock` for mutex management.
|
|
128
|
+
- Use `std::unique_lock` when deferred locking or condition variables are needed.
|
|
129
|
+
- Use `std::fstream` (auto-closes) instead of `fopen`/`fclose`.
|
|
130
|
+
- Write custom RAII wrappers for C library resources (file descriptors, handles).
|
|
131
|
+
|
|
132
|
+
## Smart Pointer Patterns
|
|
133
|
+
- `unique_ptr`: default ownership model. Transfer with `std::move`.
|
|
134
|
+
- `shared_ptr`: use only for genuinely shared ownership graphs.
|
|
135
|
+
- `weak_ptr`: break cycles in `shared_ptr` graphs. Use `lock()` to access.
|
|
136
|
+
- Factory functions should return `unique_ptr`. Let callers upgrade to `shared_ptr`.
|
|
137
|
+
- Never pass smart pointers by reference. Pass `T&` or `T*` to non-owning consumers.
|
|
138
|
+
|
|
139
|
+
## Concurrency
|
|
140
|
+
- Use `std::thread` with `std::jthread` (C++20) for auto-joining threads.
|
|
141
|
+
- Use `std::mutex` + `std::scoped_lock` for shared data protection.
|
|
142
|
+
- Use `std::atomic<T>` for lock-free single-variable synchronization.
|
|
143
|
+
- Use `std::condition_variable` for producer-consumer patterns.
|
|
144
|
+
- Use `std::async` / `std::future` for simple parallel computation.
|
|
145
|
+
- Use `std::counting_semaphore` (C++20) for resource pool limiting.
|
|
146
|
+
|
|
147
|
+
## Template Patterns
|
|
148
|
+
- Use CRTP for compile-time polymorphism (static dispatch).
|
|
149
|
+
- Use `concepts` (C++20) to constrain template parameters with clear error messages.
|
|
150
|
+
- Use `if constexpr` for compile-time branching in templates.
|
|
151
|
+
- Use variadic templates and fold expressions for parameter packs.
|
|
152
|
+
- Prefer `constexpr` functions over template metaprogramming when possible.
|
|
153
|
+
|
|
154
|
+
## Design Patterns
|
|
155
|
+
- Use `std::variant` + `std::visit` for type-safe visitor pattern.
|
|
156
|
+
- Use `std::function` for type-erased callbacks and strategy pattern.
|
|
157
|
+
- Use Pimpl idiom (`unique_ptr<Impl>`) for ABI stability and compilation firewall.
|
|
158
|
+
- Use Builder pattern with method chaining for complex object construction.
|
|
159
|
+
- Use `std::move` semantics in move constructors for efficient resource transfer.
|
|
160
|
+
|
|
161
|
+
## Anti-Patterns
|
|
162
|
+
- Raw `new`/`delete`: use smart pointers and containers.
|
|
163
|
+
- Returning raw pointers from factory functions: return `unique_ptr`.
|
|
164
|
+
- `const_cast` to remove constness: redesign the interface.
|
|
165
|
+
- Deep inheritance hierarchies: prefer composition and templates.
|
|
166
|
+
- Premature optimization over readability: profile first, optimize second.
|
|
167
|
+
|
|
168
|
+
# C++ Security
|
|
169
|
+
|
|
170
|
+
## Buffer Overflow Prevention
|
|
171
|
+
- Use `std::string`, `std::vector`, `std::array` instead of C arrays and `char[]`.
|
|
172
|
+
- Use `std::span` (C++20) for safe, bounds-checked views over contiguous data.
|
|
173
|
+
- Never use `strcpy`, `strcat`, `sprintf`. Use `std::string` operations or `snprintf`.
|
|
174
|
+
- Enable `-D_FORTIFY_SOURCE=2` in release builds for runtime buffer checks.
|
|
175
|
+
- Use `at()` for bounds-checked container access in untrusted input paths.
|
|
176
|
+
|
|
177
|
+
## Memory Safety
|
|
178
|
+
- Use smart pointers exclusively. Zero raw `new`/`delete` in application code.
|
|
179
|
+
- Enable AddressSanitizer (`-fsanitize=address`) in development and CI builds.
|
|
180
|
+
- Enable UndefinedBehaviorSanitizer (`-fsanitize=undefined`) in test builds.
|
|
181
|
+
- Use `-fstack-protector-strong` for stack buffer overflow detection.
|
|
182
|
+
- Use Valgrind for memory leak detection in integration tests.
|
|
183
|
+
|
|
184
|
+
## Integer Safety
|
|
185
|
+
- Check for overflow before arithmetic on untrusted integers.
|
|
186
|
+
- Use `std::numeric_limits<T>::max()` for boundary checks.
|
|
187
|
+
- Use unsigned types only for bit manipulation. Prefer signed for arithmetic.
|
|
188
|
+
- Use `static_cast` explicitly. Never rely on implicit narrowing conversions.
|
|
189
|
+
- Enable `-Wconversion` and `-Wsign-conversion` warnings.
|
|
190
|
+
|
|
191
|
+
## Input Validation
|
|
192
|
+
- Validate all external input: file data, network packets, command-line arguments.
|
|
193
|
+
- Use `std::stoi` / `std::stol` with exception handling for string-to-number conversion.
|
|
194
|
+
- Set maximum sizes for dynamic allocations based on untrusted input.
|
|
195
|
+
- Validate file paths to prevent directory traversal (`../`).
|
|
196
|
+
- Use allowlist validation for format specifiers and command strings.
|
|
197
|
+
|
|
198
|
+
## Secure Coding
|
|
199
|
+
- Use `std::fill` or `explicit_bzero()` to zero sensitive memory before deallocation.
|
|
200
|
+
- Use constant-time comparison for secrets (avoid timing side-channels).
|
|
201
|
+
- Use `mlock()` to prevent sensitive memory from being swapped to disk.
|
|
202
|
+
- Compile with `-fPIE -pie` for position-independent executables (ASLR).
|
|
203
|
+
- Enable `-Werror` in CI to prevent warnings from becoming vulnerabilities.
|
|
204
|
+
|
|
205
|
+
## Dependencies
|
|
206
|
+
- Audit third-party C libraries for known CVEs before inclusion.
|
|
207
|
+
- Use `vcpkg` or `Conan` with pinned versions for reproducible builds.
|
|
208
|
+
- Prefer well-maintained libraries with active security response teams.
|
|
209
|
+
- Minimize C library usage. Prefer C++ standard library equivalents.
|
|
210
|
+
|
|
211
|
+
## Concurrency Safety
|
|
212
|
+
- Use `std::mutex` with `std::scoped_lock` for all shared data access.
|
|
213
|
+
- Use `std::atomic` for lock-free single-variable operations.
|
|
214
|
+
- Enable ThreadSanitizer (`-fsanitize=thread`) in test builds for race detection.
|
|
215
|
+
- Avoid `volatile` for synchronization. It does not provide atomicity or ordering.
|
|
216
|
+
- Use RAII lock guards. Never manually `lock()`/`unlock()`.
|
|
217
|
+
|
|
218
|
+
## Compiler Hardening
|
|
219
|
+
- Enable all warnings: `-Wall -Wextra -Wpedantic`.
|
|
220
|
+
- Use `-D_GLIBCXX_ASSERTIONS` for debug iterator and container checks.
|
|
221
|
+
- Use `-fno-exceptions` only when exception safety is not required.
|
|
222
|
+
- Link with `-Wl,-z,relro,-z,now` for full RELRO (GOT hardening).
|
|
223
|
+
|
|
224
|
+
# C++ Testing
|
|
225
|
+
|
|
226
|
+
## Framework
|
|
227
|
+
- Use GoogleTest (gtest) as the primary test framework.
|
|
228
|
+
- Use GoogleMock (gmock) for mocking interfaces and virtual classes.
|
|
229
|
+
- Use Catch2 as a lightweight alternative (header-only, BDD-style).
|
|
230
|
+
- Use CTest for test discovery and execution via CMake.
|
|
231
|
+
|
|
232
|
+
## File Naming
|
|
233
|
+
- Test files: `foo_test.cpp` or `test_foo.cpp` in a dedicated `tests/` directory.
|
|
234
|
+
- Mirror source directory structure in test directory.
|
|
235
|
+
- One test file per source file or logical component.
|
|
236
|
+
- Use `CMakeLists.txt` with `add_test()` to register tests.
|
|
237
|
+
|
|
238
|
+
## Structure (GoogleTest)
|
|
239
|
+
- Use `TEST(SuiteName, TestName)` for simple tests.
|
|
240
|
+
- Use `TEST_F(FixtureName, TestName)` for tests sharing setup/teardown.
|
|
241
|
+
- Use `SetUp()` / `TearDown()` in fixtures for per-test initialization.
|
|
242
|
+
- Keep tests focused: one logical assertion per test case.
|
|
243
|
+
|
|
244
|
+
## Assertions
|
|
245
|
+
- Use `EXPECT_*` (non-fatal) by default. Use `ASSERT_*` only when continuation is meaningless.
|
|
246
|
+
- `EXPECT_EQ`, `EXPECT_NE`, `EXPECT_LT`, `EXPECT_GT` for comparisons.
|
|
247
|
+
- `EXPECT_TRUE`, `EXPECT_FALSE` for boolean conditions.
|
|
248
|
+
- `EXPECT_THROW(expr, ExceptionType)` for exception testing.
|
|
249
|
+
- `EXPECT_THAT(value, matcher)` with gmock matchers for complex assertions.
|
|
250
|
+
|
|
251
|
+
## Parameterized Tests
|
|
252
|
+
- Use `INSTANTIATE_TEST_SUITE_P` with `testing::Values(...)` for value-parameterized tests.
|
|
253
|
+
- Use `testing::Combine()` for multi-dimensional parameterization.
|
|
254
|
+
- Use `TYPED_TEST_SUITE` for type-parameterized tests across template types.
|
|
255
|
+
- Prefer parameterized tests over copy-pasting similar test bodies.
|
|
256
|
+
|
|
257
|
+
## Mocking (GoogleMock)
|
|
258
|
+
- Define mock classes: `MOCK_METHOD(ReturnType, MethodName, (Args), (Qualifiers))`.
|
|
259
|
+
- Use `EXPECT_CALL(mock, Method(matchers)).WillOnce(Return(value))`.
|
|
260
|
+
- Use `NiceMock<T>` to suppress uninteresting call warnings.
|
|
261
|
+
- Use `StrictMock<T>` to fail on any unexpected call.
|
|
262
|
+
- Use dependency injection (constructor) to pass mock objects.
|
|
263
|
+
|
|
264
|
+
## Build Integration
|
|
265
|
+
- Use `FetchContent` or `find_package` to integrate gtest in CMake.
|
|
266
|
+
- Enable `BUILD_TESTING` option to conditionally include tests.
|
|
267
|
+
- Use `ctest --output-on-failure` for CI runs.
|
|
268
|
+
- Use sanitizers in test builds: `-fsanitize=address,undefined`.
|
|
269
|
+
|
|
270
|
+
## Best Practices
|
|
271
|
+
- Test edge cases: empty input, max values, null pointers, boundary conditions.
|
|
272
|
+
- Use RAII test fixtures for resource cleanup (no manual teardown).
|
|
273
|
+
- Avoid testing private methods directly. Test through public API.
|
|
274
|
+
- Use `valgrind` or ASan/UBSan in CI to detect memory errors.
|
|
275
|
+
- Keep tests fast: mock I/O and external dependencies.
|