@softspark/ai-toolkit 1.2.1 → 1.3.0
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 +5 -29
- package/CHANGELOG.md +21 -0
- package/README.md +114 -17
- package/app/.claude-plugin/plugin.json +1 -1
- package/app/ARCHITECTURE.md +35 -19
- package/app/agents/ai-engineer.md +47 -5
- package/app/agents/fact-checker.md +1 -1
- package/app/agents/llm-ops-engineer.md +2 -2
- package/app/agents/{mcp-server-architect.md → mcp-specialist.md} +124 -18
- package/app/agents/mcp-testing-engineer.md +2 -2
- package/app/agents/nlp-engineer.md +1 -1
- package/app/agents/orchestrator.md +3 -4
- package/app/agents/project-planner.md +1 -1
- package/app/agents/technical-researcher.md +71 -21
- package/app/hooks/commit-quality.sh +53 -0
- package/app/hooks/governance-capture.sh +77 -0
- package/app/hooks/guard-config.sh +46 -0
- package/app/hooks/mcp-health.sh +53 -0
- package/app/hooks/pre-compact-save.sh +34 -0
- package/app/hooks/session-context.sh +60 -0
- package/app/hooks.json +60 -0
- package/app/mcp-templates/README.md +105 -0
- package/app/mcp-templates/brave-search.json +13 -0
- package/app/mcp-templates/cloudflare.json +14 -0
- package/app/mcp-templates/context7.json +10 -0
- package/app/mcp-templates/custom-template.json +13 -0
- package/app/mcp-templates/datadog.json +15 -0
- package/app/mcp-templates/docker.json +10 -0
- package/app/mcp-templates/fetch.json +10 -0
- package/app/mcp-templates/filesystem.json +10 -0
- package/app/mcp-templates/git.json +10 -0
- package/app/mcp-templates/github.json +13 -0
- package/app/mcp-templates/google-drive.json +15 -0
- package/app/mcp-templates/google-maps.json +13 -0
- package/app/mcp-templates/grafana.json +14 -0
- package/app/mcp-templates/linear.json +13 -0
- package/app/mcp-templates/memory.json +10 -0
- package/app/mcp-templates/notion.json +13 -0
- package/app/mcp-templates/postgres.json +10 -0
- package/app/mcp-templates/puppeteer.json +10 -0
- package/app/mcp-templates/redis.json +13 -0
- package/app/mcp-templates/sentry.json +14 -0
- package/app/mcp-templates/sequential-thinking.json +10 -0
- package/app/mcp-templates/slack.json +14 -0
- package/app/mcp-templates/sqlite.json +10 -0
- package/app/mcp-templates/supabase.json +14 -0
- package/app/mcp-templates/vercel.json +13 -0
- package/app/plugins/research-pack/README.md +1 -1
- package/app/plugins/research-pack/plugin.json +1 -1
- package/app/rules/claude-toolkit-rules.md +1 -1
- package/app/rules/common/coding-style.md +52 -0
- package/app/rules/common/git-workflow.md +45 -0
- package/app/rules/common/performance.md +49 -0
- package/app/rules/common/security.md +59 -0
- package/app/rules/common/testing.md +53 -0
- package/app/rules/cpp/coding-style.md +55 -0
- package/app/rules/cpp/frameworks.md +55 -0
- package/app/rules/cpp/patterns.md +57 -0
- package/app/rules/cpp/security.md +61 -0
- package/app/rules/cpp/testing.md +58 -0
- package/app/rules/csharp/coding-style.md +54 -0
- package/app/rules/csharp/frameworks.md +60 -0
- package/app/rules/csharp/patterns.md +61 -0
- package/app/rules/csharp/security.md +60 -0
- package/app/rules/csharp/testing.md +58 -0
- package/app/rules/dart/coding-style.md +61 -0
- package/app/rules/dart/frameworks.md +59 -0
- package/app/rules/dart/patterns.md +62 -0
- package/app/rules/dart/security.md +60 -0
- package/app/rules/dart/testing.md +60 -0
- package/app/rules/golang/coding-style.md +50 -0
- package/app/rules/golang/frameworks.md +56 -0
- package/app/rules/golang/patterns.md +52 -0
- package/app/rules/golang/security.md +61 -0
- package/app/rules/golang/testing.md +54 -0
- package/app/rules/java/coding-style.md +56 -0
- package/app/rules/java/frameworks.md +54 -0
- package/app/rules/java/patterns.md +59 -0
- package/app/rules/java/security.md +60 -0
- package/app/rules/java/testing.md +55 -0
- package/app/rules/kotlin/coding-style.md +56 -0
- package/app/rules/kotlin/frameworks.md +54 -0
- package/app/rules/kotlin/patterns.md +54 -0
- package/app/rules/kotlin/security.md +62 -0
- package/app/rules/kotlin/testing.md +56 -0
- package/app/rules/php/coding-style.md +53 -0
- package/app/rules/php/frameworks.md +57 -0
- package/app/rules/php/patterns.md +63 -0
- package/app/rules/php/security.md +61 -0
- package/app/rules/php/testing.md +60 -0
- package/app/rules/python/coding-style.md +52 -0
- package/app/rules/python/frameworks.md +53 -0
- package/app/rules/python/patterns.md +53 -0
- package/app/rules/python/security.md +58 -0
- package/app/rules/python/testing.md +52 -0
- package/app/rules/ruby/coding-style.md +56 -0
- package/app/rules/ruby/frameworks.md +56 -0
- package/app/rules/ruby/patterns.md +61 -0
- package/app/rules/ruby/security.md +61 -0
- package/app/rules/ruby/testing.md +63 -0
- package/app/rules/rust/coding-style.md +52 -0
- package/app/rules/rust/frameworks.md +59 -0
- package/app/rules/rust/patterns.md +58 -0
- package/app/rules/rust/security.md +64 -0
- package/app/rules/rust/testing.md +54 -0
- package/app/rules/swift/coding-style.md +55 -0
- package/app/rules/swift/frameworks.md +63 -0
- package/app/rules/swift/patterns.md +63 -0
- package/app/rules/swift/security.md +63 -0
- package/app/rules/swift/testing.md +60 -0
- package/app/rules/typescript/coding-style.md +51 -0
- package/app/rules/typescript/frameworks.md +51 -0
- package/app/rules/typescript/patterns.md +51 -0
- package/app/rules/typescript/security.md +55 -0
- package/app/rules/typescript/testing.md +52 -0
- package/app/skills/app-builder/SKILL.md +1 -1
- package/app/skills/brand-voice/SKILL.md +92 -0
- package/app/skills/council/SKILL.md +133 -0
- package/app/skills/introspect/SKILL.md +125 -0
- package/bin/ai-toolkit.js +103 -2
- package/kb/reference/agents-catalog.md +10 -13
- package/kb/reference/architecture-overview.md +29 -6
- package/kb/reference/commands-catalog.md +4 -4
- package/kb/reference/competitive-features-implementation.md +677 -0
- package/kb/reference/extension-api.md +175 -0
- package/kb/reference/hooks-catalog.md +90 -14
- package/kb/reference/language-rules.md +167 -0
- package/kb/reference/manifest-install.md +165 -0
- package/kb/reference/mcp-templates.md +110 -0
- package/kb/reference/skills-catalog.md +9 -6
- package/llms-full.txt +1511 -59
- package/llms.txt +8 -3
- package/package.json +2 -2
- package/scripts/inject_hook_cli.py +330 -0
- package/scripts/install.py +241 -7
- package/scripts/install_steps/ai_tools.py +63 -1
- package/scripts/install_steps/detect_language.py +50 -0
- package/scripts/install_steps/install_state.py +117 -0
- package/scripts/mcp_manager.py +206 -0
- package/app/agents/mcp-expert.md +0 -228
- package/app/agents/rag-engineer.md +0 -201
- package/app/agents/research-synthesizer.md +0 -138
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: swift
|
|
3
|
+
category: frameworks
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Swift Frameworks
|
|
8
|
+
|
|
9
|
+
## SwiftUI
|
|
10
|
+
- Use `VStack`, `HStack`, `ZStack` for layout composition.
|
|
11
|
+
- Use `List` with `ForEach` for dynamic content. Use `LazyVStack` for large lists.
|
|
12
|
+
- Use `NavigationStack` (iOS 16+) with `navigationDestination(for:)` for type-safe navigation.
|
|
13
|
+
- Use `.task { }` modifier for async data loading tied to view lifecycle.
|
|
14
|
+
- Use `@ViewBuilder` for conditional view composition in custom containers.
|
|
15
|
+
- Use `PreviewProvider` or `#Preview` macro for rapid UI iteration.
|
|
16
|
+
|
|
17
|
+
## UIKit (Legacy / Hybrid)
|
|
18
|
+
- Use `UIHostingController` to embed SwiftUI views in UIKit.
|
|
19
|
+
- Use `UIViewRepresentable` to wrap UIKit views in SwiftUI.
|
|
20
|
+
- Use Auto Layout with constraints or `UIStackView` for layout.
|
|
21
|
+
- Use `UICollectionViewCompositionalLayout` for complex collection layouts.
|
|
22
|
+
- Use `Coordinator` pattern for delegate-based UIKit interop in SwiftUI.
|
|
23
|
+
|
|
24
|
+
## Combine
|
|
25
|
+
- Use `Publisher` / `Subscriber` for reactive data streams.
|
|
26
|
+
- Use `sink` for subscribing. Store cancellables in `Set<AnyCancellable>`.
|
|
27
|
+
- Use `map`, `filter`, `flatMap`, `combineLatest` for stream transformation.
|
|
28
|
+
- Use `@Published` on class properties for automatic publisher generation.
|
|
29
|
+
- Prefer `AsyncSequence` (async/await) over Combine for new code.
|
|
30
|
+
|
|
31
|
+
## Swift Data
|
|
32
|
+
- Use `@Model` macro for persistent model definitions.
|
|
33
|
+
- Use `@Query` in SwiftUI views for automatic fetching and observation.
|
|
34
|
+
- Use `ModelContext` for CRUD operations: `context.insert(item)`, `context.delete(item)`.
|
|
35
|
+
- Use `#Predicate` macro for type-safe query filtering.
|
|
36
|
+
- Use `ModelConfiguration` for custom store locations and migration options.
|
|
37
|
+
|
|
38
|
+
## Core Data (Legacy)
|
|
39
|
+
- Use `NSPersistentContainer` for stack setup.
|
|
40
|
+
- Use `NSFetchRequest` with `NSPredicate` for querying.
|
|
41
|
+
- Use `performBackgroundTask` for background context operations.
|
|
42
|
+
- Use lightweight migrations for schema changes when possible.
|
|
43
|
+
- Prefer SwiftData for new projects (iOS 17+).
|
|
44
|
+
|
|
45
|
+
## Vapor (Server-Side)
|
|
46
|
+
- Use `routes.get("users")` for route definitions.
|
|
47
|
+
- Use `Content` protocol for request/response body codable conformance.
|
|
48
|
+
- Use Fluent ORM with migrations for database access.
|
|
49
|
+
- Use middleware for authentication, CORS, and error handling.
|
|
50
|
+
- Use `async`/`await` natively (Vapor 4+ is fully async).
|
|
51
|
+
|
|
52
|
+
## Networking
|
|
53
|
+
- Use `URLSession` with `async/await` for HTTP requests.
|
|
54
|
+
- Use `Codable` with `JSONDecoder` for response parsing.
|
|
55
|
+
- Use `URLCache` and `ETag` for response caching.
|
|
56
|
+
- Set `timeoutIntervalForRequest` on `URLSessionConfiguration`.
|
|
57
|
+
- Use `TaskLocal` for request-scoped values (tracing, auth context).
|
|
58
|
+
|
|
59
|
+
## Package Management
|
|
60
|
+
- Use Swift Package Manager (SPM) for dependency management.
|
|
61
|
+
- Define dependencies in `Package.swift` with exact version or version ranges.
|
|
62
|
+
- Use `Package.resolved` committed to the repository for reproducible builds.
|
|
63
|
+
- Prefer SPM over CocoaPods/Carthage for new projects.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: swift
|
|
3
|
+
category: patterns
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Swift Patterns
|
|
8
|
+
|
|
9
|
+
## Error Handling
|
|
10
|
+
- Use `enum AppError: Error` for typed, exhaustive error handling.
|
|
11
|
+
- Use `throws` functions with `do-catch` for recoverable errors.
|
|
12
|
+
- Use `Result<Success, Failure>` for asynchronous error propagation.
|
|
13
|
+
- Use `try?` for optional conversion. Use `try!` only in tests or guaranteed paths.
|
|
14
|
+
- Add `LocalizedError` conformance for user-facing error messages.
|
|
15
|
+
|
|
16
|
+
## Protocol-Oriented Design
|
|
17
|
+
- Define capabilities as protocols: `protocol Fetchable { func fetch() async throws -> Data }`.
|
|
18
|
+
- Use protocol extensions for default implementations.
|
|
19
|
+
- Use protocol composition: `func process(_ item: Sendable & Codable)`.
|
|
20
|
+
- Use associated types for generic protocols: `associatedtype Output`.
|
|
21
|
+
- Use `some Protocol` (opaque types) for return types hiding concrete implementations.
|
|
22
|
+
|
|
23
|
+
## Async/Await
|
|
24
|
+
- Use `async` functions for all asynchronous operations.
|
|
25
|
+
- Use `async let` for concurrent, independent operations.
|
|
26
|
+
- Use `TaskGroup` for dynamic parallelism with collected results.
|
|
27
|
+
- Use `Task { }` to bridge sync to async. Avoid `.task { }` in views for complex logic.
|
|
28
|
+
- Use `withThrowingTaskGroup` for concurrent operations that can fail.
|
|
29
|
+
|
|
30
|
+
## Actors
|
|
31
|
+
- Use `actor` for thread-safe mutable state (replaces manual locks).
|
|
32
|
+
- Use `@MainActor` for UI-related state and methods.
|
|
33
|
+
- Use `nonisolated` for actor methods that do not access mutable state.
|
|
34
|
+
- Use `GlobalActor` for custom isolation domains.
|
|
35
|
+
- Minimize `await` calls on actors to reduce suspension points.
|
|
36
|
+
|
|
37
|
+
## SwiftUI Patterns
|
|
38
|
+
- Use `@State` for view-local mutable state.
|
|
39
|
+
- Use `@Binding` for child-to-parent state communication.
|
|
40
|
+
- Use `@Observable` (Observation framework) for model objects (preferred over `@ObservedObject`).
|
|
41
|
+
- Use `@Environment` for dependency injection: `@Environment(\.modelContext)`.
|
|
42
|
+
- Use `ViewModifier` for reusable view transformations.
|
|
43
|
+
- Extract subviews into separate structs for readability and performance.
|
|
44
|
+
|
|
45
|
+
## Codable
|
|
46
|
+
- Use `Codable` for JSON serialization/deserialization.
|
|
47
|
+
- Use `CodingKeys` enum for custom key mapping.
|
|
48
|
+
- Use `JSONDecoder` with `.convertFromSnakeCase` for API compatibility.
|
|
49
|
+
- Use `@propertyWrapper` for custom decoding strategies (e.g., date formats).
|
|
50
|
+
- Use `nestedContainer` for flattening nested JSON structures.
|
|
51
|
+
|
|
52
|
+
## Dependency Injection
|
|
53
|
+
- Use initializer injection for required dependencies.
|
|
54
|
+
- Use `@Environment` in SwiftUI for framework-provided values.
|
|
55
|
+
- Use `swift-dependencies` library for testable, controlled dependency management.
|
|
56
|
+
- Use `@Dependency(\.apiClient) var apiClient` for automatic resolution.
|
|
57
|
+
|
|
58
|
+
## Anti-Patterns
|
|
59
|
+
- Force-unwrapping optionals: use `guard let` or `??`.
|
|
60
|
+
- Massive view controllers/views: split into subviews and view models.
|
|
61
|
+
- Reference cycles: use `[weak self]` in closures capturing `self`.
|
|
62
|
+
- Blocking the main thread: use `Task` or `DispatchQueue.global()`.
|
|
63
|
+
- Stringly-typed APIs: use enums, protocols, and strong types.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: swift
|
|
3
|
+
category: security
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Swift Security
|
|
8
|
+
|
|
9
|
+
## Keychain
|
|
10
|
+
- Use Keychain Services for storing passwords, tokens, and cryptographic keys.
|
|
11
|
+
- Use `kSecAttrAccessibleWhenUnlockedThisDeviceOnly` for sensitive items.
|
|
12
|
+
- Use `KeychainAccess` or similar wrapper libraries for cleaner API.
|
|
13
|
+
- Never store secrets in `UserDefaults` (unencrypted plist on disk).
|
|
14
|
+
- Delete keychain items on user logout.
|
|
15
|
+
|
|
16
|
+
## App Transport Security (ATS)
|
|
17
|
+
- Use HTTPS for all network connections. ATS enforces this by default.
|
|
18
|
+
- Never add blanket `NSAllowsArbitraryLoads` exception.
|
|
19
|
+
- Use per-domain exceptions only when connecting to legacy servers.
|
|
20
|
+
- Implement certificate pinning for high-security connections.
|
|
21
|
+
- Validate server certificates in `URLSessionDelegate` for custom pinning.
|
|
22
|
+
|
|
23
|
+
## Input Validation
|
|
24
|
+
- Validate all user input before processing or displaying.
|
|
25
|
+
- Use `NSRegularExpression` or Swift Regex for pattern validation.
|
|
26
|
+
- Sanitize strings before using in URL construction, SQL, or HTML.
|
|
27
|
+
- Validate deep link URL parameters before navigation.
|
|
28
|
+
- Limit input lengths in `UITextField` / `TextField` to prevent abuse.
|
|
29
|
+
|
|
30
|
+
## Data Protection
|
|
31
|
+
- Use `Data Protection` API: set `FileProtectionType.complete` on sensitive files.
|
|
32
|
+
- Use `CryptoKit` for hashing (`SHA256`), encryption (`AES.GCM`), and signing.
|
|
33
|
+
- Use `SecureEnclave` for hardware-backed key storage on supported devices.
|
|
34
|
+
- Zero sensitive data in memory after use: `withUnsafeMutableBytes { $0.initializeMemory(as: UInt8.self, repeating: 0) }`.
|
|
35
|
+
- Use `@Sendable` closures to prevent data races in concurrent access.
|
|
36
|
+
|
|
37
|
+
## Authentication
|
|
38
|
+
- Use `AuthenticationServices` for Sign in with Apple and passkeys.
|
|
39
|
+
- Use `LocalAuthentication` (Face ID / Touch ID) for biometric auth.
|
|
40
|
+
- Store authentication tokens in Keychain, not in memory or UserDefaults.
|
|
41
|
+
- Use short-lived access tokens with refresh token rotation.
|
|
42
|
+
- Implement session timeout for inactive users.
|
|
43
|
+
|
|
44
|
+
## Network Security
|
|
45
|
+
- Use `URLSession` with certificate pinning for sensitive API calls.
|
|
46
|
+
- Validate response `Content-Type` headers before parsing.
|
|
47
|
+
- Use `Codable` for structured deserialization (prevents injection).
|
|
48
|
+
- Set request timeouts to prevent hanging connections.
|
|
49
|
+
- Do not log request/response bodies containing sensitive data.
|
|
50
|
+
|
|
51
|
+
## Code Security
|
|
52
|
+
- Use `[weak self]` in closures to prevent retain cycles and memory leaks.
|
|
53
|
+
- Use `@Sendable` and actor isolation for thread-safe concurrent code.
|
|
54
|
+
- Avoid `UnsafePointer` / `UnsafeMutablePointer` unless absolutely necessary.
|
|
55
|
+
- Use `#if DEBUG` guards for debug-only code. Never ship debug features.
|
|
56
|
+
- Enable Xcode hardened runtime for macOS apps.
|
|
57
|
+
|
|
58
|
+
## Dependency Security
|
|
59
|
+
- Audit SPM dependencies before adding. Check maintainer reputation.
|
|
60
|
+
- Pin dependency versions in `Package.resolved`.
|
|
61
|
+
- Review `Package.swift` of dependencies for unusual build plugins.
|
|
62
|
+
- Prefer dependencies with active security response and disclosure processes.
|
|
63
|
+
- Minimize third-party dependencies for security-critical modules.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: swift
|
|
3
|
+
category: testing
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Swift Testing
|
|
8
|
+
|
|
9
|
+
## Framework
|
|
10
|
+
- Use Swift Testing (`import Testing`) for new projects (Swift 5.10+).
|
|
11
|
+
- Use XCTest for existing projects and UIKit-based UI tests.
|
|
12
|
+
- Use swift-snapshot-testing for visual regression testing.
|
|
13
|
+
- Use swift-dependencies for controlled dependency injection in tests.
|
|
14
|
+
|
|
15
|
+
## File Naming
|
|
16
|
+
- Test files: `FooTests.swift` in `Tests/` target.
|
|
17
|
+
- Mirror source module structure in test target.
|
|
18
|
+
- Use `@Test` attribute (Swift Testing) or `test` prefix (XCTest) for test methods.
|
|
19
|
+
- Use `@Suite` (Swift Testing) for test grouping.
|
|
20
|
+
|
|
21
|
+
## Structure (Swift Testing)
|
|
22
|
+
- Use `@Test("description")` for individual test cases.
|
|
23
|
+
- Use `@Test(arguments: [...])` for parameterized tests.
|
|
24
|
+
- Use `#expect(condition)` for assertions. Use `#require(condition)` for preconditions.
|
|
25
|
+
- Use `#expect(throws: FooError.self) { try riskyOperation() }` for error testing.
|
|
26
|
+
- Use `@Suite` structs for grouping. Properties serve as shared setup.
|
|
27
|
+
|
|
28
|
+
## Structure (XCTest)
|
|
29
|
+
- Use `setUp()` / `tearDown()` for per-test initialization and cleanup.
|
|
30
|
+
- Use `setUpWithError()` for throwing setup code.
|
|
31
|
+
- Use `XCTAssertEqual`, `XCTAssertTrue`, `XCTAssertNil` for assertions.
|
|
32
|
+
- Use `XCTAssertThrowsError` for exception testing.
|
|
33
|
+
- Use `expectation(description:)` + `wait(for:timeout:)` for async assertions.
|
|
34
|
+
|
|
35
|
+
## Async Testing
|
|
36
|
+
- Use `async` test functions: `@Test func fetchUser() async throws { ... }`.
|
|
37
|
+
- Use `confirmation()` (Swift Testing) for event-based async assertions.
|
|
38
|
+
- XCTest: use `XCTestExpectation` with `fulfillment()` for callback-based async.
|
|
39
|
+
- Test `AsyncSequence` with `for await` loops and assertion on collected values.
|
|
40
|
+
|
|
41
|
+
## Mocking
|
|
42
|
+
- Use protocol-based dependency injection for testability.
|
|
43
|
+
- Create manual mock implementations conforming to protocols.
|
|
44
|
+
- Use `swift-dependencies` for environment-controlled dependency overrides.
|
|
45
|
+
- Use `@Dependency` property wrapper for automatic mock injection in tests.
|
|
46
|
+
- Avoid mocking frameworks when protocol mocks are straightforward.
|
|
47
|
+
|
|
48
|
+
## UI Testing (XCTest)
|
|
49
|
+
- Use `XCUIApplication` for UI automation tests.
|
|
50
|
+
- Use accessibility identifiers for reliable element lookup.
|
|
51
|
+
- Use `app.buttons["Submit"].tap()` for interaction simulation.
|
|
52
|
+
- Use `waitForExistence(timeout:)` for async UI element appearance.
|
|
53
|
+
- Keep UI tests focused on critical user flows only (slow to run).
|
|
54
|
+
|
|
55
|
+
## Best Practices
|
|
56
|
+
- Test behavior through public API. Avoid `@testable import` when possible.
|
|
57
|
+
- Use `@testable import Module` only when testing internal members is necessary.
|
|
58
|
+
- Use `withDependencies { }` for scoped dependency overrides in tests.
|
|
59
|
+
- Test on multiple platforms (iOS, macOS) when shipping cross-platform.
|
|
60
|
+
- Run tests with `swift test` or `xcodebuild test` in CI.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: typescript
|
|
3
|
+
category: coding-style
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# TypeScript Coding Style
|
|
8
|
+
|
|
9
|
+
## Strict Mode
|
|
10
|
+
- Always use `strict: true` in tsconfig.json.
|
|
11
|
+
- Never use `any` -- use `unknown` + type guards instead.
|
|
12
|
+
- Prefer `interface` over `type` for object shapes (extendable).
|
|
13
|
+
- Use `as const` for literal types and readonly tuples.
|
|
14
|
+
|
|
15
|
+
## Naming
|
|
16
|
+
- PascalCase: types, interfaces, enums, classes, components.
|
|
17
|
+
- camelCase: variables, functions, methods, properties.
|
|
18
|
+
- UPPER_SNAKE: constants, env vars.
|
|
19
|
+
- Prefix interfaces with `I` only if project convention requires it.
|
|
20
|
+
|
|
21
|
+
## Functions
|
|
22
|
+
- Prefer arrow functions for callbacks and inline.
|
|
23
|
+
- Use `function` declarations for hoisted, named functions.
|
|
24
|
+
- Max 3 parameters -- use options object beyond that.
|
|
25
|
+
- Always type return values for public/exported functions.
|
|
26
|
+
|
|
27
|
+
## Imports
|
|
28
|
+
- Group: node builtins, external, internal, relative.
|
|
29
|
+
- Use `type` imports: `import type { Foo } from './foo'`.
|
|
30
|
+
- No barrel exports unless at package boundary.
|
|
31
|
+
- Prefer named exports over default exports.
|
|
32
|
+
|
|
33
|
+
## Types
|
|
34
|
+
- Use discriminated unions over class hierarchies for state.
|
|
35
|
+
- Use `readonly` for arrays and objects that should not be mutated.
|
|
36
|
+
- Use `satisfies` operator to validate types without widening.
|
|
37
|
+
- Prefer `unknown` over `any` at API boundaries.
|
|
38
|
+
- Use template literal types for string patterns.
|
|
39
|
+
|
|
40
|
+
## Avoid
|
|
41
|
+
- `enum` -- use `as const` objects or union types.
|
|
42
|
+
- `namespace` -- use ES modules.
|
|
43
|
+
- `private` keyword -- use `#` private fields.
|
|
44
|
+
- Non-null assertion `!` -- use proper type narrowing.
|
|
45
|
+
- `as` type casting -- use type guards and narrowing.
|
|
46
|
+
|
|
47
|
+
## Configuration
|
|
48
|
+
- Enable `noUncheckedIndexedAccess` for safer array/object access.
|
|
49
|
+
- Enable `exactOptionalPropertyTypes` to distinguish `undefined` from missing.
|
|
50
|
+
- Use `moduleResolution: "bundler"` for modern projects.
|
|
51
|
+
- Set `isolatedModules: true` for bundler compatibility.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: typescript
|
|
3
|
+
category: frameworks
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# TypeScript Frameworks
|
|
8
|
+
|
|
9
|
+
## React
|
|
10
|
+
- Use function components exclusively. No class components.
|
|
11
|
+
- Colocate state with the component that owns it. Lift only when needed.
|
|
12
|
+
- Use `useCallback` and `useMemo` only when profiling shows a need.
|
|
13
|
+
- Use `React.lazy()` + Suspense for code-splitting routes.
|
|
14
|
+
- Avoid prop drilling past 2 levels -- use Context or state management.
|
|
15
|
+
|
|
16
|
+
## Next.js (App Router)
|
|
17
|
+
- Default to Server Components. Add `"use client"` only when needed.
|
|
18
|
+
- Use Server Actions for mutations. Never expose internal APIs to client.
|
|
19
|
+
- Use `loading.tsx` and `error.tsx` for streaming and error boundaries.
|
|
20
|
+
- Fetch data in Server Components, not in useEffect on client.
|
|
21
|
+
- Use `revalidatePath` / `revalidateTag` for cache invalidation.
|
|
22
|
+
|
|
23
|
+
## Express / Fastify / Hono
|
|
24
|
+
- Use layered architecture: route -> controller -> service -> repository.
|
|
25
|
+
- Validate request body/params/query with Zod middleware.
|
|
26
|
+
- Centralize error handling in a single error middleware.
|
|
27
|
+
- Use async route handlers with proper error forwarding.
|
|
28
|
+
- Return consistent response shapes: `{ data }` or `{ error }`.
|
|
29
|
+
|
|
30
|
+
## State Management
|
|
31
|
+
- Use Zustand or Jotai for client state. Redux only for complex existing apps.
|
|
32
|
+
- Use TanStack Query (React Query) for server state.
|
|
33
|
+
- Separate server state (fetched data) from client state (UI state).
|
|
34
|
+
- Never duplicate server data in client state stores.
|
|
35
|
+
|
|
36
|
+
## ORM / Database
|
|
37
|
+
- Use Drizzle for new projects (SQL-like, type-safe, lightweight).
|
|
38
|
+
- Use Prisma for rapid prototyping (schema-first, great DX).
|
|
39
|
+
- Always use migrations. Never modify schema manually in production.
|
|
40
|
+
- Use transactions for multi-table operations.
|
|
41
|
+
|
|
42
|
+
## Node.js Runtime
|
|
43
|
+
- Use `node:` prefix for built-in modules: `import { readFile } from 'node:fs/promises'`.
|
|
44
|
+
- Prefer `fetch` (built-in since Node 18) over axios/node-fetch.
|
|
45
|
+
- Use `structuredClone()` for deep cloning.
|
|
46
|
+
- Set `"type": "module"` in package.json for ESM.
|
|
47
|
+
|
|
48
|
+
## Monorepo
|
|
49
|
+
- Use Turborepo or Nx for monorepo orchestration.
|
|
50
|
+
- Share types via internal packages, not copy-paste.
|
|
51
|
+
- Use workspace protocols: `"@org/shared": "workspace:*"`.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: typescript
|
|
3
|
+
category: patterns
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# TypeScript Patterns
|
|
8
|
+
|
|
9
|
+
## Error Handling
|
|
10
|
+
- Use Result type pattern: `{ success: true; data: T } | { success: false; error: E }`.
|
|
11
|
+
- Use Zod `.safeParse()` for validation -- returns typed result, never throws.
|
|
12
|
+
- Create domain-specific error classes extending `Error` with error codes.
|
|
13
|
+
- Centralize error handling in middleware, not in each handler.
|
|
14
|
+
- Never catch errors silently. Log or rethrow with context.
|
|
15
|
+
|
|
16
|
+
## Discriminated Unions
|
|
17
|
+
- Use discriminated unions for state machines and polymorphic data.
|
|
18
|
+
- Always include a `type` or `kind` literal field as discriminant.
|
|
19
|
+
- Use `switch` with exhaustive checking (`never` in default) on unions.
|
|
20
|
+
- Prefer unions over optional fields for mutually exclusive states.
|
|
21
|
+
|
|
22
|
+
## Async Patterns
|
|
23
|
+
- Use `async/await` everywhere. Never use raw `.then()` chains.
|
|
24
|
+
- Use `Promise.all()` for independent concurrent operations.
|
|
25
|
+
- Use `Promise.allSettled()` when some failures are acceptable.
|
|
26
|
+
- Implement cancellation with `AbortController` for long operations.
|
|
27
|
+
- Wrap callbacks in Promises at the boundary, then use async/await.
|
|
28
|
+
|
|
29
|
+
## Validation
|
|
30
|
+
- Validate at API boundaries with Zod, Valibot, or ArkType.
|
|
31
|
+
- Derive TypeScript types from schemas: `z.infer<typeof Schema>`.
|
|
32
|
+
- Never trust runtime data to match TypeScript types without validation.
|
|
33
|
+
- Use branded types for domain primitives: `UserId`, `Email`, `Slug`.
|
|
34
|
+
|
|
35
|
+
## Dependency Injection
|
|
36
|
+
- Use constructor injection for services and repositories.
|
|
37
|
+
- Accept interfaces, not concrete classes, in constructors.
|
|
38
|
+
- Use factory functions for creating configured instances.
|
|
39
|
+
- Avoid service locator pattern and global singletons.
|
|
40
|
+
|
|
41
|
+
## Immutability
|
|
42
|
+
- Use `readonly` on interface properties by default.
|
|
43
|
+
- Use `Readonly<T>`, `ReadonlyArray<T>` for function parameters.
|
|
44
|
+
- Use `Object.freeze()` only for runtime safety in config objects.
|
|
45
|
+
- Prefer spread/map/filter over mutating methods (push, splice).
|
|
46
|
+
|
|
47
|
+
## Type Guards
|
|
48
|
+
- Use `is` return type for custom type guards: `(x: unknown): x is User`.
|
|
49
|
+
- Use `in` operator for discriminating object shapes.
|
|
50
|
+
- Prefer `satisfies` over `as` for type validation without casting.
|
|
51
|
+
- Use assertion functions (`asserts x is T`) for preconditions.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: typescript
|
|
3
|
+
category: security
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# TypeScript Security
|
|
8
|
+
|
|
9
|
+
## Input Validation
|
|
10
|
+
- Validate ALL request data with Zod/Valibot at API boundary.
|
|
11
|
+
- Use `.strip()` / `.strict()` to reject unexpected fields.
|
|
12
|
+
- Validate URL params and query strings, not just request bodies.
|
|
13
|
+
- Never pass raw user input to `eval()`, `Function()`, or template literals in SQL.
|
|
14
|
+
|
|
15
|
+
## XSS Prevention
|
|
16
|
+
- Use framework auto-escaping (React JSX, Angular templates).
|
|
17
|
+
- Never use `dangerouslySetInnerHTML` without DOMPurify sanitization.
|
|
18
|
+
- Sanitize user content before storing, not just before rendering.
|
|
19
|
+
- Set CSP headers: `default-src 'self'; script-src 'self'`.
|
|
20
|
+
|
|
21
|
+
## Authentication
|
|
22
|
+
- Use `httpOnly`, `secure`, `sameSite: 'strict'` for auth cookies.
|
|
23
|
+
- Implement CSRF protection for cookie-based auth (double-submit or token).
|
|
24
|
+
- Use short-lived JWTs (15min) with refresh token rotation.
|
|
25
|
+
- Validate JWT signature, expiration, issuer, and audience on every request.
|
|
26
|
+
|
|
27
|
+
## SQL / NoSQL Injection
|
|
28
|
+
- Use parameterized queries with Drizzle/Prisma/TypeORM. Never concatenate.
|
|
29
|
+
- For raw queries, use tagged template literals: `sql\`SELECT * FROM users WHERE id = ${id}\``.
|
|
30
|
+
- Validate and cast IDs to expected types (UUID, integer) before queries.
|
|
31
|
+
- Use ORM query builders for dynamic filters.
|
|
32
|
+
|
|
33
|
+
## Dependency Security
|
|
34
|
+
- Run `npm audit` in CI. Fail on high/critical vulnerabilities.
|
|
35
|
+
- Use `npm audit signatures` to verify package provenance.
|
|
36
|
+
- Pin exact versions with lockfile. Review lockfile changes in PRs.
|
|
37
|
+
- Avoid packages with postinstall scripts unless trusted.
|
|
38
|
+
|
|
39
|
+
## Secrets
|
|
40
|
+
- Use `process.env` with Zod validation for env vars.
|
|
41
|
+
- Never import `.env` files in production -- use platform env injection.
|
|
42
|
+
- Never log `req.headers.authorization` or session tokens.
|
|
43
|
+
- Use `crypto.timingSafeEqual()` for comparing secrets.
|
|
44
|
+
|
|
45
|
+
## Server Hardening
|
|
46
|
+
- Set security headers: HSTS, X-Content-Type-Options, X-Frame-Options.
|
|
47
|
+
- Use `helmet` middleware in Express, built-in security in Fastify.
|
|
48
|
+
- Implement rate limiting on all endpoints (`express-rate-limit`, `@fastify/rate-limit`).
|
|
49
|
+
- Disable `X-Powered-By` header. Do not expose server technology.
|
|
50
|
+
|
|
51
|
+
## File Uploads
|
|
52
|
+
- Validate file type by magic bytes, not just extension or MIME type.
|
|
53
|
+
- Set maximum file size limits on the server.
|
|
54
|
+
- Store uploads outside the web root. Serve through a proxy with CDN.
|
|
55
|
+
- Generate random filenames. Never use user-provided filenames for storage.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
language: typescript
|
|
3
|
+
category: testing
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# TypeScript Testing
|
|
8
|
+
|
|
9
|
+
## Framework
|
|
10
|
+
- Use Vitest for new projects (faster, native ESM, TypeScript-first).
|
|
11
|
+
- Use Jest only for existing projects already using it.
|
|
12
|
+
- Use Playwright for E2E browser testing.
|
|
13
|
+
- Use Supertest or built-in fetch for API integration tests.
|
|
14
|
+
|
|
15
|
+
## File Naming
|
|
16
|
+
- Test files: `*.test.ts` or `*.spec.ts` colocated with source.
|
|
17
|
+
- Test utilities: `tests/helpers/` or `tests/utils/`.
|
|
18
|
+
- Fixtures: `tests/fixtures/` with typed factory functions.
|
|
19
|
+
|
|
20
|
+
## Structure
|
|
21
|
+
- Use `describe` for grouping by function/class/feature.
|
|
22
|
+
- Use `it` with behavior descriptions: `it('returns 404 when user not found')`.
|
|
23
|
+
- Avoid deeply nested `describe` blocks (max 2 levels).
|
|
24
|
+
- Use `beforeEach` for setup, avoid `beforeAll` for mutable state.
|
|
25
|
+
|
|
26
|
+
## Type-Safe Mocking
|
|
27
|
+
- Use `vi.fn()` with type parameters: `vi.fn<[string], Promise<User>>()`.
|
|
28
|
+
- Use `vi.mock()` for module-level mocking.
|
|
29
|
+
- Prefer dependency injection over module mocking for testability.
|
|
30
|
+
- Use `vi.spyOn()` for partial mocks on existing objects.
|
|
31
|
+
|
|
32
|
+
## React/Component Testing
|
|
33
|
+
- Use React Testing Library. Query by role, label, text -- not test IDs.
|
|
34
|
+
- Use `userEvent` over `fireEvent` for realistic user interactions.
|
|
35
|
+
- Test behavior and rendered output, not component internals.
|
|
36
|
+
- Use `renderHook` for testing custom hooks in isolation.
|
|
37
|
+
|
|
38
|
+
## Assertions
|
|
39
|
+
- Use `expect().toBe()` for primitives, `expect().toEqual()` for objects.
|
|
40
|
+
- Use `expect().toMatchInlineSnapshot()` for complex output verification.
|
|
41
|
+
- Avoid `toBeTruthy/toBeFalsy` -- use specific matchers.
|
|
42
|
+
- Use `expect().rejects.toThrow()` for async error testing.
|
|
43
|
+
|
|
44
|
+
## Async Testing
|
|
45
|
+
- Always `await` async operations. Never use `done` callback.
|
|
46
|
+
- Use `vi.useFakeTimers()` for timer-dependent code.
|
|
47
|
+
- Use `waitFor` from Testing Library for async DOM updates.
|
|
48
|
+
|
|
49
|
+
## Performance
|
|
50
|
+
- Run tests in parallel (Vitest default). Isolate state to enable this.
|
|
51
|
+
- Use `vi.mock()` for heavy dependencies (DB, network) in unit tests.
|
|
52
|
+
- Keep unit test suite under 30 seconds.
|
|
@@ -18,7 +18,7 @@ allowed-tools: Read
|
|
|
18
18
|
| mobile, ios, android | Mobile App | mobile-developer |
|
|
19
19
|
| cli, command, terminal | CLI Tool | backend-specialist |
|
|
20
20
|
| game, unity, godot | Game | game-developer |
|
|
21
|
-
| ai, ml, rag | AI/ML |
|
|
21
|
+
| ai, ml, rag | AI/ML | ai-engineer |
|
|
22
22
|
| e-commerce, shop, store | E-commerce | backend + frontend |
|
|
23
23
|
|
|
24
24
|
---
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: brand-voice
|
|
3
|
+
description: "Loaded when writing documentation, content, README, or user-facing text. Prevents generic LLM rhetoric and enforces direct, technical voice."
|
|
4
|
+
effort: medium
|
|
5
|
+
user-invocable: false
|
|
6
|
+
allowed-tools: Read
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Brand Voice
|
|
10
|
+
|
|
11
|
+
Auto-loaded when writing documentation, content, or user-facing text. Enforces consistent, direct voice and eliminates LLM rhetoric.
|
|
12
|
+
|
|
13
|
+
## Anti-Trope List (Banned Phrases)
|
|
14
|
+
|
|
15
|
+
### Opening Tropes (Never Start With)
|
|
16
|
+
|
|
17
|
+
- "In today's fast-paced world..."
|
|
18
|
+
- "In the ever-evolving landscape of..."
|
|
19
|
+
- "Let's dive into..."
|
|
20
|
+
- "Let's explore..."
|
|
21
|
+
- "Welcome to this comprehensive guide..."
|
|
22
|
+
- "Are you looking for...?"
|
|
23
|
+
- "Whether you're a beginner or an expert..."
|
|
24
|
+
|
|
25
|
+
### Filler Adjectives (Remove or Replace)
|
|
26
|
+
|
|
27
|
+
| Banned | Replacement |
|
|
28
|
+
|--------|------------|
|
|
29
|
+
| "cutting-edge" | Describe what it does |
|
|
30
|
+
| "game-changer" | State the specific impact |
|
|
31
|
+
| "revolutionary" | State the concrete improvement |
|
|
32
|
+
| "robust" | Describe what makes it reliable |
|
|
33
|
+
| "seamless" | Describe the integration mechanism |
|
|
34
|
+
| "state-of-the-art" | Cite specific capabilities |
|
|
35
|
+
| "leveraging" | "using" |
|
|
36
|
+
| "harnessing" | "using" |
|
|
37
|
+
| "utilizing" | "using" |
|
|
38
|
+
| "delve" / "delve into" | "examine" / "look at" |
|
|
39
|
+
| "holistic" | "complete" / "full" |
|
|
40
|
+
| "synergy" | Describe the actual interaction |
|
|
41
|
+
| "paradigm shift" | Describe the change |
|
|
42
|
+
| "best-in-class" | Cite the benchmark or drop it |
|
|
43
|
+
| "empower" | Say what it enables |
|
|
44
|
+
| "streamline" | Say what step it removes |
|
|
45
|
+
| "elevate" | Say what improves and by how much |
|
|
46
|
+
| "unlock" | Say what becomes possible |
|
|
47
|
+
|
|
48
|
+
### Closing Tropes (Never End With)
|
|
49
|
+
|
|
50
|
+
- "Happy coding!"
|
|
51
|
+
- "And that's it! You're all set!"
|
|
52
|
+
- "I hope this helps!"
|
|
53
|
+
- "Feel free to reach out if you have any questions"
|
|
54
|
+
- "Now go build something amazing!"
|
|
55
|
+
|
|
56
|
+
### Structural Tropes
|
|
57
|
+
|
|
58
|
+
- Do not number every single point when prose works better
|
|
59
|
+
- Do not use headers for 2-sentence sections
|
|
60
|
+
- Do not add a "Conclusion" section that restates the intro
|
|
61
|
+
- Do not add "Overview" sections that say nothing the title didn't already say
|
|
62
|
+
- Do not pad lists to look longer than they are
|
|
63
|
+
|
|
64
|
+
## Voice Principles
|
|
65
|
+
|
|
66
|
+
| Principle | Rule |
|
|
67
|
+
|-----------|------|
|
|
68
|
+
| **Direct over diplomatic** | Say what you mean. "This function is slow" not "This function could potentially benefit from optimization." |
|
|
69
|
+
| **Specific over general** | Numbers, names, versions. "Reduces cold start by 40ms" not "Improves performance significantly." |
|
|
70
|
+
| **Evidence over assertion** | Show, don't tell. Include benchmarks, examples, or code. |
|
|
71
|
+
| **Short over long** | One sentence beats three. Cut filler words on every pass. |
|
|
72
|
+
| **Active over passive** | "The function returns X" not "X is returned by the function." |
|
|
73
|
+
| **Technical over casual** | Match the audience's expertise. Never dumb down for developers. |
|
|
74
|
+
| **Honest over promotional** | State limitations alongside strengths. |
|
|
75
|
+
|
|
76
|
+
## Sentence-Level Rules
|
|
77
|
+
|
|
78
|
+
- **Lead with the action or outcome**, not the context. Bad: "In order to configure X, you need to..." Good: "Configure X by..."
|
|
79
|
+
- **Cut weasel words**: "quite", "very", "really", "basically", "simply", "just", "actually", "arguably"
|
|
80
|
+
- **One idea per sentence.** If a sentence has "and" linking two distinct ideas, split it.
|
|
81
|
+
- **Use concrete subjects.** Bad: "It is important to note that..." Good: (delete the phrase, state the fact)
|
|
82
|
+
|
|
83
|
+
## Before Publishing Checklist
|
|
84
|
+
|
|
85
|
+
- [ ] No banned phrases from anti-trope list?
|
|
86
|
+
- [ ] Opening sentence provides value (not filler)?
|
|
87
|
+
- [ ] Every adjective earns its place (can you remove it without losing meaning)?
|
|
88
|
+
- [ ] No "comprehensive guide" or "complete overview" unless it truly is?
|
|
89
|
+
- [ ] Consistent terminology throughout?
|
|
90
|
+
- [ ] Active voice used by default?
|
|
91
|
+
- [ ] No weasel words remaining?
|
|
92
|
+
- [ ] Technical claims backed by evidence or examples?
|