@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,29 +1,29 @@
|
|
|
1
|
-
# Testing Requirements
|
|
2
|
-
|
|
3
|
-
## Minimum Test Coverage: 80%
|
|
4
|
-
|
|
5
|
-
Test Types (ALL required):
|
|
6
|
-
1. **Unit Tests** - Individual functions, utilities, components
|
|
7
|
-
2. **Integration Tests** - API endpoints, database operations
|
|
8
|
-
3. **E2E Tests** - Critical user flows (framework chosen per language)
|
|
9
|
-
|
|
10
|
-
## Test-Driven Development
|
|
11
|
-
|
|
12
|
-
MANDATORY workflow:
|
|
13
|
-
1. Write test first (RED)
|
|
14
|
-
2. Run test - it should FAIL
|
|
15
|
-
3. Write minimal implementation (GREEN)
|
|
16
|
-
4. Run test - it should PASS
|
|
17
|
-
5. Refactor (IMPROVE)
|
|
18
|
-
6. Verify coverage (80%+)
|
|
19
|
-
|
|
20
|
-
## Troubleshooting Test Failures
|
|
21
|
-
|
|
22
|
-
1. Use **tdd-guide** agent
|
|
23
|
-
2. Check test isolation
|
|
24
|
-
3. Verify mocks are correct
|
|
25
|
-
4. Fix implementation, not tests (unless tests are wrong)
|
|
26
|
-
|
|
27
|
-
## Agent Support
|
|
28
|
-
|
|
29
|
-
- **tdd-guide** - Use PROACTIVELY for new features, enforces write-tests-first
|
|
1
|
+
# Testing Requirements
|
|
2
|
+
|
|
3
|
+
## Minimum Test Coverage: 80%
|
|
4
|
+
|
|
5
|
+
Test Types (ALL required):
|
|
6
|
+
1. **Unit Tests** - Individual functions, utilities, components
|
|
7
|
+
2. **Integration Tests** - API endpoints, database operations
|
|
8
|
+
3. **E2E Tests** - Critical user flows (framework chosen per language)
|
|
9
|
+
|
|
10
|
+
## Test-Driven Development
|
|
11
|
+
|
|
12
|
+
MANDATORY workflow:
|
|
13
|
+
1. Write test first (RED)
|
|
14
|
+
2. Run test - it should FAIL
|
|
15
|
+
3. Write minimal implementation (GREEN)
|
|
16
|
+
4. Run test - it should PASS
|
|
17
|
+
5. Refactor (IMPROVE)
|
|
18
|
+
6. Verify coverage (80%+)
|
|
19
|
+
|
|
20
|
+
## Troubleshooting Test Failures
|
|
21
|
+
|
|
22
|
+
1. Use **tdd-guide** agent
|
|
23
|
+
2. Check test isolation
|
|
24
|
+
3. Verify mocks are correct
|
|
25
|
+
4. Fix implementation, not tests (unless tests are wrong)
|
|
26
|
+
|
|
27
|
+
## Agent Support
|
|
28
|
+
|
|
29
|
+
- **tdd-guide** - Use PROACTIVELY for new features, enforces write-tests-first
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
---
|
|
2
|
-
paths:
|
|
3
|
-
- "**/*.go"
|
|
4
|
-
- "**/go.mod"
|
|
5
|
-
- "**/go.sum"
|
|
6
|
-
---
|
|
7
|
-
# Go Coding Style
|
|
8
|
-
|
|
9
|
-
> This file extends [common/coding-style.md](../common/coding-style.md) with Go specific content.
|
|
10
|
-
|
|
11
|
-
## Formatting
|
|
12
|
-
|
|
13
|
-
- **gofmt** and **goimports** are mandatory — no style debates
|
|
14
|
-
|
|
15
|
-
## Design Principles
|
|
16
|
-
|
|
17
|
-
- Accept interfaces, return structs
|
|
18
|
-
- Keep interfaces small (1-3 methods)
|
|
19
|
-
|
|
20
|
-
## Error Handling
|
|
21
|
-
|
|
22
|
-
Always wrap errors with context:
|
|
23
|
-
|
|
24
|
-
```go
|
|
25
|
-
if err != nil {
|
|
26
|
-
return fmt.Errorf("failed to create user: %w", err)
|
|
27
|
-
}
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Reference
|
|
31
|
-
|
|
32
|
-
See skill: `golang-patterns` for comprehensive Go idioms and patterns.
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "**/*.go"
|
|
4
|
+
- "**/go.mod"
|
|
5
|
+
- "**/go.sum"
|
|
6
|
+
---
|
|
7
|
+
# Go Coding Style
|
|
8
|
+
|
|
9
|
+
> This file extends [common/coding-style.md](../common/coding-style.md) with Go specific content.
|
|
10
|
+
|
|
11
|
+
## Formatting
|
|
12
|
+
|
|
13
|
+
- **gofmt** and **goimports** are mandatory — no style debates
|
|
14
|
+
|
|
15
|
+
## Design Principles
|
|
16
|
+
|
|
17
|
+
- Accept interfaces, return structs
|
|
18
|
+
- Keep interfaces small (1-3 methods)
|
|
19
|
+
|
|
20
|
+
## Error Handling
|
|
21
|
+
|
|
22
|
+
Always wrap errors with context:
|
|
23
|
+
|
|
24
|
+
```go
|
|
25
|
+
if err != nil {
|
|
26
|
+
return fmt.Errorf("failed to create user: %w", err)
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Reference
|
|
31
|
+
|
|
32
|
+
See skill: `golang-patterns` for comprehensive Go idioms and patterns.
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
---
|
|
2
|
-
paths:
|
|
3
|
-
- "**/*.go"
|
|
4
|
-
- "**/go.mod"
|
|
5
|
-
- "**/go.sum"
|
|
6
|
-
---
|
|
7
|
-
# Go Hooks
|
|
8
|
-
|
|
9
|
-
> This file extends [common/hooks.md](../common/hooks.md) with Go specific content.
|
|
10
|
-
|
|
11
|
-
## PostToolUse Hooks
|
|
12
|
-
|
|
13
|
-
Configure in `~/.claude/settings.json`:
|
|
14
|
-
|
|
15
|
-
- **gofmt/goimports**: Auto-format `.go` files after edit
|
|
16
|
-
- **go vet**: Run static analysis after editing `.go` files
|
|
17
|
-
- **staticcheck**: Run extended static checks on modified packages
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "**/*.go"
|
|
4
|
+
- "**/go.mod"
|
|
5
|
+
- "**/go.sum"
|
|
6
|
+
---
|
|
7
|
+
# Go Hooks
|
|
8
|
+
|
|
9
|
+
> This file extends [common/hooks.md](../common/hooks.md) with Go specific content.
|
|
10
|
+
|
|
11
|
+
## PostToolUse Hooks
|
|
12
|
+
|
|
13
|
+
Configure in `~/.claude/settings.json`:
|
|
14
|
+
|
|
15
|
+
- **gofmt/goimports**: Auto-format `.go` files after edit
|
|
16
|
+
- **go vet**: Run static analysis after editing `.go` files
|
|
17
|
+
- **staticcheck**: Run extended static checks on modified packages
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
---
|
|
2
|
-
paths:
|
|
3
|
-
- "**/*.go"
|
|
4
|
-
- "**/go.mod"
|
|
5
|
-
- "**/go.sum"
|
|
6
|
-
---
|
|
7
|
-
# Go Patterns
|
|
8
|
-
|
|
9
|
-
> This file extends [common/patterns.md](../common/patterns.md) with Go specific content.
|
|
10
|
-
|
|
11
|
-
## Functional Options
|
|
12
|
-
|
|
13
|
-
```go
|
|
14
|
-
type Option func(*Server)
|
|
15
|
-
|
|
16
|
-
func WithPort(port int) Option {
|
|
17
|
-
return func(s *Server) { s.port = port }
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
func NewServer(opts ...Option) *Server {
|
|
21
|
-
s := &Server{port: 8080}
|
|
22
|
-
for _, opt := range opts {
|
|
23
|
-
opt(s)
|
|
24
|
-
}
|
|
25
|
-
return s
|
|
26
|
-
}
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Small Interfaces
|
|
30
|
-
|
|
31
|
-
Define interfaces where they are used, not where they are implemented.
|
|
32
|
-
|
|
33
|
-
## Dependency Injection
|
|
34
|
-
|
|
35
|
-
Use constructor functions to inject dependencies:
|
|
36
|
-
|
|
37
|
-
```go
|
|
38
|
-
func NewUserService(repo UserRepository, logger Logger) *UserService {
|
|
39
|
-
return &UserService{repo: repo, logger: logger}
|
|
40
|
-
}
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Reference
|
|
44
|
-
|
|
45
|
-
See skill: `golang-patterns` for comprehensive Go patterns including concurrency, error handling, and package organization.
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "**/*.go"
|
|
4
|
+
- "**/go.mod"
|
|
5
|
+
- "**/go.sum"
|
|
6
|
+
---
|
|
7
|
+
# Go Patterns
|
|
8
|
+
|
|
9
|
+
> This file extends [common/patterns.md](../common/patterns.md) with Go specific content.
|
|
10
|
+
|
|
11
|
+
## Functional Options
|
|
12
|
+
|
|
13
|
+
```go
|
|
14
|
+
type Option func(*Server)
|
|
15
|
+
|
|
16
|
+
func WithPort(port int) Option {
|
|
17
|
+
return func(s *Server) { s.port = port }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
func NewServer(opts ...Option) *Server {
|
|
21
|
+
s := &Server{port: 8080}
|
|
22
|
+
for _, opt := range opts {
|
|
23
|
+
opt(s)
|
|
24
|
+
}
|
|
25
|
+
return s
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Small Interfaces
|
|
30
|
+
|
|
31
|
+
Define interfaces where they are used, not where they are implemented.
|
|
32
|
+
|
|
33
|
+
## Dependency Injection
|
|
34
|
+
|
|
35
|
+
Use constructor functions to inject dependencies:
|
|
36
|
+
|
|
37
|
+
```go
|
|
38
|
+
func NewUserService(repo UserRepository, logger Logger) *UserService {
|
|
39
|
+
return &UserService{repo: repo, logger: logger}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Reference
|
|
44
|
+
|
|
45
|
+
See skill: `golang-patterns` for comprehensive Go patterns including concurrency, error handling, and package organization.
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
---
|
|
2
|
-
paths:
|
|
3
|
-
- "**/*.go"
|
|
4
|
-
- "**/go.mod"
|
|
5
|
-
- "**/go.sum"
|
|
6
|
-
---
|
|
7
|
-
# Go Security
|
|
8
|
-
|
|
9
|
-
> This file extends [common/security.md](../common/security.md) with Go specific content.
|
|
10
|
-
|
|
11
|
-
## Secret Management
|
|
12
|
-
|
|
13
|
-
```go
|
|
14
|
-
apiKey := os.Getenv("OPENAI_API_KEY")
|
|
15
|
-
if apiKey == "" {
|
|
16
|
-
log.Fatal("OPENAI_API_KEY not configured")
|
|
17
|
-
}
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Security Scanning
|
|
21
|
-
|
|
22
|
-
- Use **gosec** for static security analysis:
|
|
23
|
-
```bash
|
|
24
|
-
gosec ./...
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Context & Timeouts
|
|
28
|
-
|
|
29
|
-
Always use `context.Context` for timeout control:
|
|
30
|
-
|
|
31
|
-
```go
|
|
32
|
-
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
|
33
|
-
defer cancel()
|
|
34
|
-
```
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "**/*.go"
|
|
4
|
+
- "**/go.mod"
|
|
5
|
+
- "**/go.sum"
|
|
6
|
+
---
|
|
7
|
+
# Go Security
|
|
8
|
+
|
|
9
|
+
> This file extends [common/security.md](../common/security.md) with Go specific content.
|
|
10
|
+
|
|
11
|
+
## Secret Management
|
|
12
|
+
|
|
13
|
+
```go
|
|
14
|
+
apiKey := os.Getenv("OPENAI_API_KEY")
|
|
15
|
+
if apiKey == "" {
|
|
16
|
+
log.Fatal("OPENAI_API_KEY not configured")
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Security Scanning
|
|
21
|
+
|
|
22
|
+
- Use **gosec** for static security analysis:
|
|
23
|
+
```bash
|
|
24
|
+
gosec ./...
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Context & Timeouts
|
|
28
|
+
|
|
29
|
+
Always use `context.Context` for timeout control:
|
|
30
|
+
|
|
31
|
+
```go
|
|
32
|
+
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
|
33
|
+
defer cancel()
|
|
34
|
+
```
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
---
|
|
2
|
-
paths:
|
|
3
|
-
- "**/*.go"
|
|
4
|
-
- "**/go.mod"
|
|
5
|
-
- "**/go.sum"
|
|
6
|
-
---
|
|
7
|
-
# Go Testing
|
|
8
|
-
|
|
9
|
-
> This file extends [common/testing.md](../common/testing.md) with Go specific content.
|
|
10
|
-
|
|
11
|
-
## Framework
|
|
12
|
-
|
|
13
|
-
Use the standard `go test` with **table-driven tests**.
|
|
14
|
-
|
|
15
|
-
## Race Detection
|
|
16
|
-
|
|
17
|
-
Always run with the `-race` flag:
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
go test -race ./...
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Coverage
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
go test -cover ./...
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Reference
|
|
30
|
-
|
|
31
|
-
See skill: `golang-testing` for detailed Go testing patterns and helpers.
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "**/*.go"
|
|
4
|
+
- "**/go.mod"
|
|
5
|
+
- "**/go.sum"
|
|
6
|
+
---
|
|
7
|
+
# Go Testing
|
|
8
|
+
|
|
9
|
+
> This file extends [common/testing.md](../common/testing.md) with Go specific content.
|
|
10
|
+
|
|
11
|
+
## Framework
|
|
12
|
+
|
|
13
|
+
Use the standard `go test` with **table-driven tests**.
|
|
14
|
+
|
|
15
|
+
## Race Detection
|
|
16
|
+
|
|
17
|
+
Always run with the `-race` flag:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
go test -race ./...
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Coverage
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
go test -cover ./...
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Reference
|
|
30
|
+
|
|
31
|
+
See skill: `golang-testing` for detailed Go testing patterns and helpers.
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
---
|
|
2
|
-
paths:
|
|
3
|
-
- "**/*.py"
|
|
4
|
-
- "**/*.pyi"
|
|
5
|
-
---
|
|
6
|
-
# Python Coding Style
|
|
7
|
-
|
|
8
|
-
> This file extends [common/coding-style.md](../common/coding-style.md) with Python specific content.
|
|
9
|
-
|
|
10
|
-
## Standards
|
|
11
|
-
|
|
12
|
-
- Follow **PEP 8** conventions
|
|
13
|
-
- Use **type annotations** on all function signatures
|
|
14
|
-
|
|
15
|
-
## Immutability
|
|
16
|
-
|
|
17
|
-
Prefer immutable data structures:
|
|
18
|
-
|
|
19
|
-
```python
|
|
20
|
-
from dataclasses import dataclass
|
|
21
|
-
|
|
22
|
-
@dataclass(frozen=True)
|
|
23
|
-
class User:
|
|
24
|
-
name: str
|
|
25
|
-
email: str
|
|
26
|
-
|
|
27
|
-
from typing import NamedTuple
|
|
28
|
-
|
|
29
|
-
class Point(NamedTuple):
|
|
30
|
-
x: float
|
|
31
|
-
y: float
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## Formatting
|
|
35
|
-
|
|
36
|
-
- **black** for code formatting
|
|
37
|
-
- **isort** for import sorting
|
|
38
|
-
- **ruff** for linting
|
|
39
|
-
|
|
40
|
-
## Reference
|
|
41
|
-
|
|
42
|
-
See skill: `python-patterns` for comprehensive Python idioms and patterns.
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "**/*.py"
|
|
4
|
+
- "**/*.pyi"
|
|
5
|
+
---
|
|
6
|
+
# Python Coding Style
|
|
7
|
+
|
|
8
|
+
> This file extends [common/coding-style.md](../common/coding-style.md) with Python specific content.
|
|
9
|
+
|
|
10
|
+
## Standards
|
|
11
|
+
|
|
12
|
+
- Follow **PEP 8** conventions
|
|
13
|
+
- Use **type annotations** on all function signatures
|
|
14
|
+
|
|
15
|
+
## Immutability
|
|
16
|
+
|
|
17
|
+
Prefer immutable data structures:
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from dataclasses import dataclass
|
|
21
|
+
|
|
22
|
+
@dataclass(frozen=True)
|
|
23
|
+
class User:
|
|
24
|
+
name: str
|
|
25
|
+
email: str
|
|
26
|
+
|
|
27
|
+
from typing import NamedTuple
|
|
28
|
+
|
|
29
|
+
class Point(NamedTuple):
|
|
30
|
+
x: float
|
|
31
|
+
y: float
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Formatting
|
|
35
|
+
|
|
36
|
+
- **black** for code formatting
|
|
37
|
+
- **isort** for import sorting
|
|
38
|
+
- **ruff** for linting
|
|
39
|
+
|
|
40
|
+
## Reference
|
|
41
|
+
|
|
42
|
+
See skill: `python-patterns` for comprehensive Python idioms and patterns.
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
---
|
|
2
|
-
paths:
|
|
3
|
-
- "**/*.py"
|
|
4
|
-
- "**/*.pyi"
|
|
5
|
-
---
|
|
6
|
-
# Python Hooks
|
|
7
|
-
|
|
8
|
-
> This file extends [common/hooks.md](../common/hooks.md) with Python specific content.
|
|
9
|
-
|
|
10
|
-
## PostToolUse Hooks
|
|
11
|
-
|
|
12
|
-
Configure in `~/.claude/settings.json`:
|
|
13
|
-
|
|
14
|
-
- **black/ruff**: Auto-format `.py` files after edit
|
|
15
|
-
- **mypy/pyright**: Run type checking after editing `.py` files
|
|
16
|
-
|
|
17
|
-
## Warnings
|
|
18
|
-
|
|
19
|
-
- Warn about `print()` statements in edited files (use `logging` module instead)
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "**/*.py"
|
|
4
|
+
- "**/*.pyi"
|
|
5
|
+
---
|
|
6
|
+
# Python Hooks
|
|
7
|
+
|
|
8
|
+
> This file extends [common/hooks.md](../common/hooks.md) with Python specific content.
|
|
9
|
+
|
|
10
|
+
## PostToolUse Hooks
|
|
11
|
+
|
|
12
|
+
Configure in `~/.claude/settings.json`:
|
|
13
|
+
|
|
14
|
+
- **black/ruff**: Auto-format `.py` files after edit
|
|
15
|
+
- **mypy/pyright**: Run type checking after editing `.py` files
|
|
16
|
+
|
|
17
|
+
## Warnings
|
|
18
|
+
|
|
19
|
+
- Warn about `print()` statements in edited files (use `logging` module instead)
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
---
|
|
2
|
-
paths:
|
|
3
|
-
- "**/*.py"
|
|
4
|
-
- "**/*.pyi"
|
|
5
|
-
---
|
|
6
|
-
# Python Patterns
|
|
7
|
-
|
|
8
|
-
> This file extends [common/patterns.md](../common/patterns.md) with Python specific content.
|
|
9
|
-
|
|
10
|
-
## Protocol (Duck Typing)
|
|
11
|
-
|
|
12
|
-
```python
|
|
13
|
-
from typing import Protocol
|
|
14
|
-
|
|
15
|
-
class Repository(Protocol):
|
|
16
|
-
def find_by_id(self, id: str) -> dict | None: ...
|
|
17
|
-
def save(self, entity: dict) -> dict: ...
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Dataclasses as DTOs
|
|
21
|
-
|
|
22
|
-
```python
|
|
23
|
-
from dataclasses import dataclass
|
|
24
|
-
|
|
25
|
-
@dataclass
|
|
26
|
-
class CreateUserRequest:
|
|
27
|
-
name: str
|
|
28
|
-
email: str
|
|
29
|
-
age: int | None = None
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Context Managers & Generators
|
|
33
|
-
|
|
34
|
-
- Use context managers (`with` statement) for resource management
|
|
35
|
-
- Use generators for lazy evaluation and memory-efficient iteration
|
|
36
|
-
|
|
37
|
-
## Reference
|
|
38
|
-
|
|
39
|
-
See skill: `python-patterns` for comprehensive patterns including decorators, concurrency, and package organization.
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "**/*.py"
|
|
4
|
+
- "**/*.pyi"
|
|
5
|
+
---
|
|
6
|
+
# Python Patterns
|
|
7
|
+
|
|
8
|
+
> This file extends [common/patterns.md](../common/patterns.md) with Python specific content.
|
|
9
|
+
|
|
10
|
+
## Protocol (Duck Typing)
|
|
11
|
+
|
|
12
|
+
```python
|
|
13
|
+
from typing import Protocol
|
|
14
|
+
|
|
15
|
+
class Repository(Protocol):
|
|
16
|
+
def find_by_id(self, id: str) -> dict | None: ...
|
|
17
|
+
def save(self, entity: dict) -> dict: ...
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Dataclasses as DTOs
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from dataclasses import dataclass
|
|
24
|
+
|
|
25
|
+
@dataclass
|
|
26
|
+
class CreateUserRequest:
|
|
27
|
+
name: str
|
|
28
|
+
email: str
|
|
29
|
+
age: int | None = None
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Context Managers & Generators
|
|
33
|
+
|
|
34
|
+
- Use context managers (`with` statement) for resource management
|
|
35
|
+
- Use generators for lazy evaluation and memory-efficient iteration
|
|
36
|
+
|
|
37
|
+
## Reference
|
|
38
|
+
|
|
39
|
+
See skill: `python-patterns` for comprehensive patterns including decorators, concurrency, and package organization.
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
---
|
|
2
|
-
paths:
|
|
3
|
-
- "**/*.py"
|
|
4
|
-
- "**/*.pyi"
|
|
5
|
-
---
|
|
6
|
-
# Python Security
|
|
7
|
-
|
|
8
|
-
> This file extends [common/security.md](../common/security.md) with Python specific content.
|
|
9
|
-
|
|
10
|
-
## Secret Management
|
|
11
|
-
|
|
12
|
-
```python
|
|
13
|
-
import os
|
|
14
|
-
from dotenv import load_dotenv
|
|
15
|
-
|
|
16
|
-
load_dotenv()
|
|
17
|
-
|
|
18
|
-
api_key = os.environ["OPENAI_API_KEY"] # Raises KeyError if missing
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Security Scanning
|
|
22
|
-
|
|
23
|
-
- Use **bandit** for static security analysis:
|
|
24
|
-
```bash
|
|
25
|
-
bandit -r src/
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Reference
|
|
29
|
-
|
|
30
|
-
See skill: `django-security` for Django-specific security guidelines (if applicable).
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- "**/*.py"
|
|
4
|
+
- "**/*.pyi"
|
|
5
|
+
---
|
|
6
|
+
# Python Security
|
|
7
|
+
|
|
8
|
+
> This file extends [common/security.md](../common/security.md) with Python specific content.
|
|
9
|
+
|
|
10
|
+
## Secret Management
|
|
11
|
+
|
|
12
|
+
```python
|
|
13
|
+
import os
|
|
14
|
+
from dotenv import load_dotenv
|
|
15
|
+
|
|
16
|
+
load_dotenv()
|
|
17
|
+
|
|
18
|
+
api_key = os.environ["OPENAI_API_KEY"] # Raises KeyError if missing
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Security Scanning
|
|
22
|
+
|
|
23
|
+
- Use **bandit** for static security analysis:
|
|
24
|
+
```bash
|
|
25
|
+
bandit -r src/
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Reference
|
|
29
|
+
|
|
30
|
+
See skill: `django-security` for Django-specific security guidelines (if applicable).
|