@cregis-dev/cckit 0.6.5 → 0.6.7
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/README.md +221 -221
- package/package.json +1 -1
- package/registry.json +145 -128
- package/src/cli.js +79 -79
- package/src/commands/init.js +174 -161
- package/src/commands/status.js +125 -85
- package/src/commands/update.js +192 -151
- package/src/core/config.js +82 -74
- package/src/core/orchestrator.js +79 -79
- package/src/core/registry.js +60 -60
- package/src/steps/add-plugin.js +148 -0
- package/src/steps/configure-user.js +181 -181
- package/src/steps/enable-plugins.js +97 -97
- package/src/steps/install-bmad.js +85 -85
- package/src/steps/install-mcp.js +70 -70
- package/src/steps/install-rules.js +69 -69
- package/src/steps/install-skills.js +56 -56
- package/src/utils/compare-versions.js +106 -0
- package/src/utils/fs.js +33 -33
- package/src/utils/manifest.js +101 -99
- package/src/utils/prompt.js +41 -41
- package/templates/mcp/claude-code/.mcp.json +40 -40
- package/templates/rules/README.md +103 -103
- package/templates/rules/common/agents.md +49 -49
- package/templates/rules/common/coding-style.md +48 -48
- package/templates/rules/common/development-workflow.md +37 -37
- package/templates/rules/common/git-workflow.md +24 -24
- package/templates/rules/common/hooks.md +30 -30
- package/templates/rules/common/patterns.md +31 -31
- package/templates/rules/common/performance.md +55 -55
- package/templates/rules/common/security.md +29 -29
- package/templates/rules/common/testing.md +29 -29
- package/templates/rules/golang/coding-style.md +32 -32
- package/templates/rules/golang/hooks.md +17 -17
- package/templates/rules/golang/patterns.md +45 -45
- package/templates/rules/golang/security.md +34 -34
- package/templates/rules/golang/testing.md +31 -31
- package/templates/rules/python/coding-style.md +42 -42
- package/templates/rules/python/hooks.md +19 -19
- package/templates/rules/python/patterns.md +39 -39
- package/templates/rules/python/security.md +30 -30
- package/templates/rules/python/testing.md +38 -38
- package/templates/rules/swift/coding-style.md +47 -47
- package/templates/rules/swift/hooks.md +20 -20
- package/templates/rules/swift/patterns.md +66 -66
- package/templates/rules/swift/security.md +33 -33
- package/templates/rules/swift/testing.md +45 -45
- package/templates/rules/typescript/coding-style.md +65 -65
- package/templates/rules/typescript/hooks.md +22 -22
- package/templates/rules/typescript/patterns.md +52 -52
- package/templates/rules/typescript/security.md +28 -28
- package/templates/rules/typescript/testing.md +18 -18
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
---
|
|
2
|
-
paths:
|
|
3
|
-
- "**/*.py"
|
|
4
|
-
- "**/*.pyi"
|
|
5
|
-
---
|
|
6
|
-
# Python Testing
|
|
7
|
-
|
|
8
|
-
> This file extends [common/testing.md](../common/testing.md) with Python specific content.
|
|
9
|
-
|
|
10
|
-
## Framework
|
|
11
|
-
|
|
12
|
-
Use **pytest** as the testing framework.
|
|
13
|
-
|
|
14
|
-
## Coverage
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
pytest --cov=src --cov-report=term-missing
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Test Organization
|
|
21
|
-
|
|
22
|
-
Use `pytest.mark` for test categorization:
|
|
23
|
-
|
|
24
|
-
```python
|
|
25
|
-
import pytest
|
|
26
|
-
|
|
27
|
-
@pytest.mark.unit
|
|
28
|
-
def test_calculate_total():
|
|
29
|
-
...
|
|
30
|
-
|
|
31
|
-
@pytest.mark.integration
|
|
32
|
-
def test_database_connection():
|
|
33
|
-
...
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Reference
|
|
37
|
-
|
|
38
|
-
See skill: `python-testing` for detailed pytest patterns and fixtures.
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "**/*.py"
|
|
4
|
+
- "**/*.pyi"
|
|
5
|
+
---
|
|
6
|
+
# Python Testing
|
|
7
|
+
|
|
8
|
+
> This file extends [common/testing.md](../common/testing.md) with Python specific content.
|
|
9
|
+
|
|
10
|
+
## Framework
|
|
11
|
+
|
|
12
|
+
Use **pytest** as the testing framework.
|
|
13
|
+
|
|
14
|
+
## Coverage
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pytest --cov=src --cov-report=term-missing
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Test Organization
|
|
21
|
+
|
|
22
|
+
Use `pytest.mark` for test categorization:
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
import pytest
|
|
26
|
+
|
|
27
|
+
@pytest.mark.unit
|
|
28
|
+
def test_calculate_total():
|
|
29
|
+
...
|
|
30
|
+
|
|
31
|
+
@pytest.mark.integration
|
|
32
|
+
def test_database_connection():
|
|
33
|
+
...
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Reference
|
|
37
|
+
|
|
38
|
+
See skill: `python-testing` for detailed pytest patterns and fixtures.
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
---
|
|
2
|
-
paths:
|
|
3
|
-
- "**/*.swift"
|
|
4
|
-
- "**/Package.swift"
|
|
5
|
-
---
|
|
6
|
-
# Swift Coding Style
|
|
7
|
-
|
|
8
|
-
> This file extends [common/coding-style.md](../common/coding-style.md) with Swift specific content.
|
|
9
|
-
|
|
10
|
-
## Formatting
|
|
11
|
-
|
|
12
|
-
- **SwiftFormat** for auto-formatting, **SwiftLint** for style enforcement
|
|
13
|
-
- `swift-format` is bundled with Xcode 16+ as an alternative
|
|
14
|
-
|
|
15
|
-
## Immutability
|
|
16
|
-
|
|
17
|
-
- Prefer `let` over `var` — define everything as `let` and only change to `var` if the compiler requires it
|
|
18
|
-
- Use `struct` with value semantics by default; use `class` only when identity or reference semantics are needed
|
|
19
|
-
|
|
20
|
-
## Naming
|
|
21
|
-
|
|
22
|
-
Follow [Apple API Design Guidelines](https://www.swift.org/documentation/api-design-guidelines/):
|
|
23
|
-
|
|
24
|
-
- Clarity at the point of use — omit needless words
|
|
25
|
-
- Name methods and properties for their roles, not their types
|
|
26
|
-
- Use `static let` for constants over global constants
|
|
27
|
-
|
|
28
|
-
## Error Handling
|
|
29
|
-
|
|
30
|
-
Use typed throws (Swift 6+) and pattern matching:
|
|
31
|
-
|
|
32
|
-
```swift
|
|
33
|
-
func load(id: String) throws(LoadError) -> Item {
|
|
34
|
-
guard let data = try? read(from: path) else {
|
|
35
|
-
throw .fileNotFound(id)
|
|
36
|
-
}
|
|
37
|
-
return try decode(data)
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## Concurrency
|
|
42
|
-
|
|
43
|
-
Enable Swift 6 strict concurrency checking. Prefer:
|
|
44
|
-
|
|
45
|
-
- `Sendable` value types for data crossing isolation boundaries
|
|
46
|
-
- Actors for shared mutable state
|
|
47
|
-
- Structured concurrency (`async let`, `TaskGroup`) over unstructured `Task {}`
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "**/*.swift"
|
|
4
|
+
- "**/Package.swift"
|
|
5
|
+
---
|
|
6
|
+
# Swift Coding Style
|
|
7
|
+
|
|
8
|
+
> This file extends [common/coding-style.md](../common/coding-style.md) with Swift specific content.
|
|
9
|
+
|
|
10
|
+
## Formatting
|
|
11
|
+
|
|
12
|
+
- **SwiftFormat** for auto-formatting, **SwiftLint** for style enforcement
|
|
13
|
+
- `swift-format` is bundled with Xcode 16+ as an alternative
|
|
14
|
+
|
|
15
|
+
## Immutability
|
|
16
|
+
|
|
17
|
+
- Prefer `let` over `var` — define everything as `let` and only change to `var` if the compiler requires it
|
|
18
|
+
- Use `struct` with value semantics by default; use `class` only when identity or reference semantics are needed
|
|
19
|
+
|
|
20
|
+
## Naming
|
|
21
|
+
|
|
22
|
+
Follow [Apple API Design Guidelines](https://www.swift.org/documentation/api-design-guidelines/):
|
|
23
|
+
|
|
24
|
+
- Clarity at the point of use — omit needless words
|
|
25
|
+
- Name methods and properties for their roles, not their types
|
|
26
|
+
- Use `static let` for constants over global constants
|
|
27
|
+
|
|
28
|
+
## Error Handling
|
|
29
|
+
|
|
30
|
+
Use typed throws (Swift 6+) and pattern matching:
|
|
31
|
+
|
|
32
|
+
```swift
|
|
33
|
+
func load(id: String) throws(LoadError) -> Item {
|
|
34
|
+
guard let data = try? read(from: path) else {
|
|
35
|
+
throw .fileNotFound(id)
|
|
36
|
+
}
|
|
37
|
+
return try decode(data)
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Concurrency
|
|
42
|
+
|
|
43
|
+
Enable Swift 6 strict concurrency checking. Prefer:
|
|
44
|
+
|
|
45
|
+
- `Sendable` value types for data crossing isolation boundaries
|
|
46
|
+
- Actors for shared mutable state
|
|
47
|
+
- Structured concurrency (`async let`, `TaskGroup`) over unstructured `Task {}`
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
---
|
|
2
|
-
paths:
|
|
3
|
-
- "**/*.swift"
|
|
4
|
-
- "**/Package.swift"
|
|
5
|
-
---
|
|
6
|
-
# Swift Hooks
|
|
7
|
-
|
|
8
|
-
> This file extends [common/hooks.md](../common/hooks.md) with Swift specific content.
|
|
9
|
-
|
|
10
|
-
## PostToolUse Hooks
|
|
11
|
-
|
|
12
|
-
Configure in `~/.claude/settings.json`:
|
|
13
|
-
|
|
14
|
-
- **SwiftFormat**: Auto-format `.swift` files after edit
|
|
15
|
-
- **SwiftLint**: Run lint checks after editing `.swift` files
|
|
16
|
-
- **swift build**: Type-check modified packages after edit
|
|
17
|
-
|
|
18
|
-
## Warning
|
|
19
|
-
|
|
20
|
-
Flag `print()` statements — use `os.Logger` or structured logging instead for production code.
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "**/*.swift"
|
|
4
|
+
- "**/Package.swift"
|
|
5
|
+
---
|
|
6
|
+
# Swift Hooks
|
|
7
|
+
|
|
8
|
+
> This file extends [common/hooks.md](../common/hooks.md) with Swift specific content.
|
|
9
|
+
|
|
10
|
+
## PostToolUse Hooks
|
|
11
|
+
|
|
12
|
+
Configure in `~/.claude/settings.json`:
|
|
13
|
+
|
|
14
|
+
- **SwiftFormat**: Auto-format `.swift` files after edit
|
|
15
|
+
- **SwiftLint**: Run lint checks after editing `.swift` files
|
|
16
|
+
- **swift build**: Type-check modified packages after edit
|
|
17
|
+
|
|
18
|
+
## Warning
|
|
19
|
+
|
|
20
|
+
Flag `print()` statements — use `os.Logger` or structured logging instead for production code.
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
---
|
|
2
|
-
paths:
|
|
3
|
-
- "**/*.swift"
|
|
4
|
-
- "**/Package.swift"
|
|
5
|
-
---
|
|
6
|
-
# Swift Patterns
|
|
7
|
-
|
|
8
|
-
> This file extends [common/patterns.md](../common/patterns.md) with Swift specific content.
|
|
9
|
-
|
|
10
|
-
## Protocol-Oriented Design
|
|
11
|
-
|
|
12
|
-
Define small, focused protocols. Use protocol extensions for shared defaults:
|
|
13
|
-
|
|
14
|
-
```swift
|
|
15
|
-
protocol Repository: Sendable {
|
|
16
|
-
associatedtype Item: Identifiable & Sendable
|
|
17
|
-
func find(by id: Item.ID) async throws -> Item?
|
|
18
|
-
func save(_ item: Item) async throws
|
|
19
|
-
}
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## Value Types
|
|
23
|
-
|
|
24
|
-
- Use structs for data transfer objects and models
|
|
25
|
-
- Use enums with associated values to model distinct states:
|
|
26
|
-
|
|
27
|
-
```swift
|
|
28
|
-
enum LoadState<T: Sendable>: Sendable {
|
|
29
|
-
case idle
|
|
30
|
-
case loading
|
|
31
|
-
case loaded(T)
|
|
32
|
-
case failed(Error)
|
|
33
|
-
}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Actor Pattern
|
|
37
|
-
|
|
38
|
-
Use actors for shared mutable state instead of locks or dispatch queues:
|
|
39
|
-
|
|
40
|
-
```swift
|
|
41
|
-
actor Cache<Key: Hashable & Sendable, Value: Sendable> {
|
|
42
|
-
private var storage: [Key: Value] = [:]
|
|
43
|
-
|
|
44
|
-
func get(_ key: Key) -> Value? { storage[key] }
|
|
45
|
-
func set(_ key: Key, value: Value) { storage[key] = value }
|
|
46
|
-
}
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Dependency Injection
|
|
50
|
-
|
|
51
|
-
Inject protocols with default parameters — production uses defaults, tests inject mocks:
|
|
52
|
-
|
|
53
|
-
```swift
|
|
54
|
-
struct UserService {
|
|
55
|
-
private let repository: any UserRepository
|
|
56
|
-
|
|
57
|
-
init(repository: any UserRepository = DefaultUserRepository()) {
|
|
58
|
-
self.repository = repository
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
## References
|
|
64
|
-
|
|
65
|
-
See skill: `swift-actor-persistence` for actor-based persistence patterns.
|
|
66
|
-
See skill: `swift-protocol-di-testing` for protocol-based DI and testing.
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "**/*.swift"
|
|
4
|
+
- "**/Package.swift"
|
|
5
|
+
---
|
|
6
|
+
# Swift Patterns
|
|
7
|
+
|
|
8
|
+
> This file extends [common/patterns.md](../common/patterns.md) with Swift specific content.
|
|
9
|
+
|
|
10
|
+
## Protocol-Oriented Design
|
|
11
|
+
|
|
12
|
+
Define small, focused protocols. Use protocol extensions for shared defaults:
|
|
13
|
+
|
|
14
|
+
```swift
|
|
15
|
+
protocol Repository: Sendable {
|
|
16
|
+
associatedtype Item: Identifiable & Sendable
|
|
17
|
+
func find(by id: Item.ID) async throws -> Item?
|
|
18
|
+
func save(_ item: Item) async throws
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Value Types
|
|
23
|
+
|
|
24
|
+
- Use structs for data transfer objects and models
|
|
25
|
+
- Use enums with associated values to model distinct states:
|
|
26
|
+
|
|
27
|
+
```swift
|
|
28
|
+
enum LoadState<T: Sendable>: Sendable {
|
|
29
|
+
case idle
|
|
30
|
+
case loading
|
|
31
|
+
case loaded(T)
|
|
32
|
+
case failed(Error)
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Actor Pattern
|
|
37
|
+
|
|
38
|
+
Use actors for shared mutable state instead of locks or dispatch queues:
|
|
39
|
+
|
|
40
|
+
```swift
|
|
41
|
+
actor Cache<Key: Hashable & Sendable, Value: Sendable> {
|
|
42
|
+
private var storage: [Key: Value] = [:]
|
|
43
|
+
|
|
44
|
+
func get(_ key: Key) -> Value? { storage[key] }
|
|
45
|
+
func set(_ key: Key, value: Value) { storage[key] = value }
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Dependency Injection
|
|
50
|
+
|
|
51
|
+
Inject protocols with default parameters — production uses defaults, tests inject mocks:
|
|
52
|
+
|
|
53
|
+
```swift
|
|
54
|
+
struct UserService {
|
|
55
|
+
private let repository: any UserRepository
|
|
56
|
+
|
|
57
|
+
init(repository: any UserRepository = DefaultUserRepository()) {
|
|
58
|
+
self.repository = repository
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## References
|
|
64
|
+
|
|
65
|
+
See skill: `swift-actor-persistence` for actor-based persistence patterns.
|
|
66
|
+
See skill: `swift-protocol-di-testing` for protocol-based DI and testing.
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
---
|
|
2
|
-
paths:
|
|
3
|
-
- "**/*.swift"
|
|
4
|
-
- "**/Package.swift"
|
|
5
|
-
---
|
|
6
|
-
# Swift Security
|
|
7
|
-
|
|
8
|
-
> This file extends [common/security.md](../common/security.md) with Swift specific content.
|
|
9
|
-
|
|
10
|
-
## Secret Management
|
|
11
|
-
|
|
12
|
-
- Use **Keychain Services** for sensitive data (tokens, passwords, keys) — never `UserDefaults`
|
|
13
|
-
- Use environment variables or `.xcconfig` files for build-time secrets
|
|
14
|
-
- Never hardcode secrets in source — decompilation tools extract them trivially
|
|
15
|
-
|
|
16
|
-
```swift
|
|
17
|
-
let apiKey = ProcessInfo.processInfo.environment["API_KEY"]
|
|
18
|
-
guard let apiKey, !apiKey.isEmpty else {
|
|
19
|
-
fatalError("API_KEY not configured")
|
|
20
|
-
}
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Transport Security
|
|
24
|
-
|
|
25
|
-
- App Transport Security (ATS) is enforced by default — do not disable it
|
|
26
|
-
- Use certificate pinning for critical endpoints
|
|
27
|
-
- Validate all server certificates
|
|
28
|
-
|
|
29
|
-
## Input Validation
|
|
30
|
-
|
|
31
|
-
- Sanitize all user input before display to prevent injection
|
|
32
|
-
- Use `URL(string:)` with validation rather than force-unwrapping
|
|
33
|
-
- Validate data from external sources (APIs, deep links, pasteboard) before processing
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "**/*.swift"
|
|
4
|
+
- "**/Package.swift"
|
|
5
|
+
---
|
|
6
|
+
# Swift Security
|
|
7
|
+
|
|
8
|
+
> This file extends [common/security.md](../common/security.md) with Swift specific content.
|
|
9
|
+
|
|
10
|
+
## Secret Management
|
|
11
|
+
|
|
12
|
+
- Use **Keychain Services** for sensitive data (tokens, passwords, keys) — never `UserDefaults`
|
|
13
|
+
- Use environment variables or `.xcconfig` files for build-time secrets
|
|
14
|
+
- Never hardcode secrets in source — decompilation tools extract them trivially
|
|
15
|
+
|
|
16
|
+
```swift
|
|
17
|
+
let apiKey = ProcessInfo.processInfo.environment["API_KEY"]
|
|
18
|
+
guard let apiKey, !apiKey.isEmpty else {
|
|
19
|
+
fatalError("API_KEY not configured")
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Transport Security
|
|
24
|
+
|
|
25
|
+
- App Transport Security (ATS) is enforced by default — do not disable it
|
|
26
|
+
- Use certificate pinning for critical endpoints
|
|
27
|
+
- Validate all server certificates
|
|
28
|
+
|
|
29
|
+
## Input Validation
|
|
30
|
+
|
|
31
|
+
- Sanitize all user input before display to prevent injection
|
|
32
|
+
- Use `URL(string:)` with validation rather than force-unwrapping
|
|
33
|
+
- Validate data from external sources (APIs, deep links, pasteboard) before processing
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
---
|
|
2
|
-
paths:
|
|
3
|
-
- "**/*.swift"
|
|
4
|
-
- "**/Package.swift"
|
|
5
|
-
---
|
|
6
|
-
# Swift Testing
|
|
7
|
-
|
|
8
|
-
> This file extends [common/testing.md](../common/testing.md) with Swift specific content.
|
|
9
|
-
|
|
10
|
-
## Framework
|
|
11
|
-
|
|
12
|
-
Use **Swift Testing** (`import Testing`) for new tests. Use `@Test` and `#expect`:
|
|
13
|
-
|
|
14
|
-
```swift
|
|
15
|
-
@Test("User creation validates email")
|
|
16
|
-
func userCreationValidatesEmail() throws {
|
|
17
|
-
#expect(throws: ValidationError.invalidEmail) {
|
|
18
|
-
try User(email: "not-an-email")
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Test Isolation
|
|
24
|
-
|
|
25
|
-
Each test gets a fresh instance — set up in `init`, tear down in `deinit`. No shared mutable state between tests.
|
|
26
|
-
|
|
27
|
-
## Parameterized Tests
|
|
28
|
-
|
|
29
|
-
```swift
|
|
30
|
-
@Test("Validates formats", arguments: ["json", "xml", "csv"])
|
|
31
|
-
func validatesFormat(format: String) throws {
|
|
32
|
-
let parser = try Parser(format: format)
|
|
33
|
-
#expect(parser.isValid)
|
|
34
|
-
}
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Coverage
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
swift test --enable-code-coverage
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Reference
|
|
44
|
-
|
|
45
|
-
See skill: `swift-protocol-di-testing` for protocol-based dependency injection and mock patterns with Swift Testing.
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "**/*.swift"
|
|
4
|
+
- "**/Package.swift"
|
|
5
|
+
---
|
|
6
|
+
# Swift Testing
|
|
7
|
+
|
|
8
|
+
> This file extends [common/testing.md](../common/testing.md) with Swift specific content.
|
|
9
|
+
|
|
10
|
+
## Framework
|
|
11
|
+
|
|
12
|
+
Use **Swift Testing** (`import Testing`) for new tests. Use `@Test` and `#expect`:
|
|
13
|
+
|
|
14
|
+
```swift
|
|
15
|
+
@Test("User creation validates email")
|
|
16
|
+
func userCreationValidatesEmail() throws {
|
|
17
|
+
#expect(throws: ValidationError.invalidEmail) {
|
|
18
|
+
try User(email: "not-an-email")
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Test Isolation
|
|
24
|
+
|
|
25
|
+
Each test gets a fresh instance — set up in `init`, tear down in `deinit`. No shared mutable state between tests.
|
|
26
|
+
|
|
27
|
+
## Parameterized Tests
|
|
28
|
+
|
|
29
|
+
```swift
|
|
30
|
+
@Test("Validates formats", arguments: ["json", "xml", "csv"])
|
|
31
|
+
func validatesFormat(format: String) throws {
|
|
32
|
+
let parser = try Parser(format: format)
|
|
33
|
+
#expect(parser.isValid)
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Coverage
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
swift test --enable-code-coverage
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Reference
|
|
44
|
+
|
|
45
|
+
See skill: `swift-protocol-di-testing` for protocol-based dependency injection and mock patterns with Swift Testing.
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
---
|
|
2
|
-
paths:
|
|
3
|
-
- "**/*.ts"
|
|
4
|
-
- "**/*.tsx"
|
|
5
|
-
- "**/*.js"
|
|
6
|
-
- "**/*.jsx"
|
|
7
|
-
---
|
|
8
|
-
# TypeScript/JavaScript Coding Style
|
|
9
|
-
|
|
10
|
-
> This file extends [common/coding-style.md](../common/coding-style.md) with TypeScript/JavaScript specific content.
|
|
11
|
-
|
|
12
|
-
## Immutability
|
|
13
|
-
|
|
14
|
-
Use spread operator for immutable updates:
|
|
15
|
-
|
|
16
|
-
```typescript
|
|
17
|
-
// WRONG: Mutation
|
|
18
|
-
function updateUser(user, name) {
|
|
19
|
-
user.name = name // MUTATION!
|
|
20
|
-
return user
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// CORRECT: Immutability
|
|
24
|
-
function updateUser(user, name) {
|
|
25
|
-
return {
|
|
26
|
-
...user,
|
|
27
|
-
name
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Error Handling
|
|
33
|
-
|
|
34
|
-
Use async/await with try-catch:
|
|
35
|
-
|
|
36
|
-
```typescript
|
|
37
|
-
try {
|
|
38
|
-
const result = await riskyOperation()
|
|
39
|
-
return result
|
|
40
|
-
} catch (error) {
|
|
41
|
-
console.error('Operation failed:', error)
|
|
42
|
-
throw new Error('Detailed user-friendly message')
|
|
43
|
-
}
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Input Validation
|
|
47
|
-
|
|
48
|
-
Use Zod for schema-based validation:
|
|
49
|
-
|
|
50
|
-
```typescript
|
|
51
|
-
import { z } from 'zod'
|
|
52
|
-
|
|
53
|
-
const schema = z.object({
|
|
54
|
-
email: z.string().email(),
|
|
55
|
-
age: z.number().int().min(0).max(150)
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
const validated = schema.parse(input)
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Console.log
|
|
62
|
-
|
|
63
|
-
- No `console.log` statements in production code
|
|
64
|
-
- Use proper logging libraries instead
|
|
65
|
-
- See hooks for automatic detection
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "**/*.ts"
|
|
4
|
+
- "**/*.tsx"
|
|
5
|
+
- "**/*.js"
|
|
6
|
+
- "**/*.jsx"
|
|
7
|
+
---
|
|
8
|
+
# TypeScript/JavaScript Coding Style
|
|
9
|
+
|
|
10
|
+
> This file extends [common/coding-style.md](../common/coding-style.md) with TypeScript/JavaScript specific content.
|
|
11
|
+
|
|
12
|
+
## Immutability
|
|
13
|
+
|
|
14
|
+
Use spread operator for immutable updates:
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
// WRONG: Mutation
|
|
18
|
+
function updateUser(user, name) {
|
|
19
|
+
user.name = name // MUTATION!
|
|
20
|
+
return user
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// CORRECT: Immutability
|
|
24
|
+
function updateUser(user, name) {
|
|
25
|
+
return {
|
|
26
|
+
...user,
|
|
27
|
+
name
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Error Handling
|
|
33
|
+
|
|
34
|
+
Use async/await with try-catch:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
try {
|
|
38
|
+
const result = await riskyOperation()
|
|
39
|
+
return result
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error('Operation failed:', error)
|
|
42
|
+
throw new Error('Detailed user-friendly message')
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Input Validation
|
|
47
|
+
|
|
48
|
+
Use Zod for schema-based validation:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { z } from 'zod'
|
|
52
|
+
|
|
53
|
+
const schema = z.object({
|
|
54
|
+
email: z.string().email(),
|
|
55
|
+
age: z.number().int().min(0).max(150)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
const validated = schema.parse(input)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Console.log
|
|
62
|
+
|
|
63
|
+
- No `console.log` statements in production code
|
|
64
|
+
- Use proper logging libraries instead
|
|
65
|
+
- See hooks for automatic detection
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
---
|
|
2
|
-
paths:
|
|
3
|
-
- "**/*.ts"
|
|
4
|
-
- "**/*.tsx"
|
|
5
|
-
- "**/*.js"
|
|
6
|
-
- "**/*.jsx"
|
|
7
|
-
---
|
|
8
|
-
# TypeScript/JavaScript Hooks
|
|
9
|
-
|
|
10
|
-
> This file extends [common/hooks.md](../common/hooks.md) with TypeScript/JavaScript specific content.
|
|
11
|
-
|
|
12
|
-
## PostToolUse Hooks
|
|
13
|
-
|
|
14
|
-
Configure in `~/.claude/settings.json`:
|
|
15
|
-
|
|
16
|
-
- **Prettier**: Auto-format JS/TS files after edit
|
|
17
|
-
- **TypeScript check**: Run `tsc` after editing `.ts`/`.tsx` files
|
|
18
|
-
- **console.log warning**: Warn about `console.log` in edited files
|
|
19
|
-
|
|
20
|
-
## Stop Hooks
|
|
21
|
-
|
|
22
|
-
- **console.log audit**: Check all modified files for `console.log` before session ends
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "**/*.ts"
|
|
4
|
+
- "**/*.tsx"
|
|
5
|
+
- "**/*.js"
|
|
6
|
+
- "**/*.jsx"
|
|
7
|
+
---
|
|
8
|
+
# TypeScript/JavaScript Hooks
|
|
9
|
+
|
|
10
|
+
> This file extends [common/hooks.md](../common/hooks.md) with TypeScript/JavaScript specific content.
|
|
11
|
+
|
|
12
|
+
## PostToolUse Hooks
|
|
13
|
+
|
|
14
|
+
Configure in `~/.claude/settings.json`:
|
|
15
|
+
|
|
16
|
+
- **Prettier**: Auto-format JS/TS files after edit
|
|
17
|
+
- **TypeScript check**: Run `tsc` after editing `.ts`/`.tsx` files
|
|
18
|
+
- **console.log warning**: Warn about `console.log` in edited files
|
|
19
|
+
|
|
20
|
+
## Stop Hooks
|
|
21
|
+
|
|
22
|
+
- **console.log audit**: Check all modified files for `console.log` before session ends
|