@chc880/everything-antigravity 1.0.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/LICENSE +21 -0
- package/README.md +54 -0
- package/assets/rules/common/coding-style.md +53 -0
- package/assets/rules/common/git-workflow.md +47 -0
- package/assets/rules/common/patterns.md +36 -0
- package/assets/rules/common/performance.md +21 -0
- package/assets/rules/common/security.md +34 -0
- package/assets/rules/common/testing.md +29 -0
- package/assets/rules/golang/coding-style.md +40 -0
- package/assets/rules/golang/patterns.md +44 -0
- package/assets/rules/golang/security.md +33 -0
- package/assets/rules/golang/testing.md +30 -0
- package/assets/rules/python/coding-style.md +52 -0
- package/assets/rules/python/patterns.md +39 -0
- package/assets/rules/python/security.md +30 -0
- package/assets/rules/python/testing.md +38 -0
- package/assets/rules/typescript/coding-style.md +44 -0
- package/assets/rules/typescript/patterns.md +50 -0
- package/assets/rules/typescript/security.md +27 -0
- package/assets/rules/typescript/testing.md +24 -0
- package/assets/skills/agent-guides/SKILL.md +40 -0
- package/assets/skills/agent-guides/references/architect.md +209 -0
- package/assets/skills/agent-guides/references/build-error-resolver.md +530 -0
- package/assets/skills/agent-guides/references/code-reviewer.md +102 -0
- package/assets/skills/agent-guides/references/database-reviewer.md +652 -0
- package/assets/skills/agent-guides/references/doc-updater.md +450 -0
- package/assets/skills/agent-guides/references/e2e-runner.md +795 -0
- package/assets/skills/agent-guides/references/go-build-resolver.md +366 -0
- package/assets/skills/agent-guides/references/go-reviewer.md +265 -0
- package/assets/skills/agent-guides/references/planner.md +117 -0
- package/assets/skills/agent-guides/references/python-reviewer.md +467 -0
- package/assets/skills/agent-guides/references/refactor-cleaner.md +304 -0
- package/assets/skills/agent-guides/references/security-reviewer.md +543 -0
- package/assets/skills/agent-guides/references/tdd-guide.md +278 -0
- package/assets/skills/backend-patterns/SKILL.md +587 -0
- package/assets/skills/clickhouse-io/SKILL.md +429 -0
- package/assets/skills/coding-standards/SKILL.md +520 -0
- package/assets/skills/cpp-testing/SKILL.md +322 -0
- package/assets/skills/django-patterns/SKILL.md +733 -0
- package/assets/skills/django-security/SKILL.md +592 -0
- package/assets/skills/django-tdd/SKILL.md +728 -0
- package/assets/skills/django-verification/SKILL.md +460 -0
- package/assets/skills/frontend-patterns/SKILL.md +631 -0
- package/assets/skills/golang-patterns/SKILL.md +673 -0
- package/assets/skills/golang-testing/SKILL.md +719 -0
- package/assets/skills/java-coding-standards/SKILL.md +138 -0
- package/assets/skills/jpa-patterns/SKILL.md +141 -0
- package/assets/skills/knowledge-management/SKILL.md +77 -0
- package/assets/skills/nutrient-document-processing/SKILL.md +165 -0
- package/assets/skills/postgres-patterns/SKILL.md +146 -0
- package/assets/skills/python-patterns/SKILL.md +749 -0
- package/assets/skills/python-testing/SKILL.md +815 -0
- package/assets/skills/security-hardening/SKILL.md +76 -0
- package/assets/skills/security-review/SKILL.md +494 -0
- package/assets/skills/security-review/cloud-infrastructure-security.md +361 -0
- package/assets/skills/springboot-patterns/SKILL.md +304 -0
- package/assets/skills/springboot-security/SKILL.md +119 -0
- package/assets/skills/springboot-tdd/SKILL.md +157 -0
- package/assets/skills/springboot-verification/SKILL.md +100 -0
- package/assets/skills/tdd-workflow/SKILL.md +409 -0
- package/assets/workflows/build-fix.md +50 -0
- package/assets/workflows/code-review.md +61 -0
- package/assets/workflows/e2e.md +65 -0
- package/assets/workflows/go-build.md +39 -0
- package/assets/workflows/go-review.md +44 -0
- package/assets/workflows/go-test.md +61 -0
- package/assets/workflows/plan.md +93 -0
- package/assets/workflows/python-review.md +95 -0
- package/assets/workflows/setup-pm.md +36 -0
- package/assets/workflows/tdd.md +75 -0
- package/assets/workflows/verify.md +81 -0
- package/bin/cli.js +69 -0
- package/lib/installer.js +301 -0
- package/package.json +34 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 NeoChen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Everything Antigravity
|
|
2
|
+
|
|
3
|
+
> 从 [Everything Claude Code](https://github.com/affaan-m/everything-claude-code) 提取核心价值,为 Antigravity 原生重写的最佳实践合集。
|
|
4
|
+
|
|
5
|
+
## 快速开始
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# 1. 全局安装
|
|
9
|
+
npm install -g @chc880/everything-antigravity
|
|
10
|
+
|
|
11
|
+
# 2. 进入你的项目,初始化
|
|
12
|
+
cd your-project
|
|
13
|
+
ea init
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
就这么简单。26 个 Skills + 11 个 Workflows + 18 条 Rules 一步到位。
|
|
17
|
+
|
|
18
|
+
## 命令
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
ea init # 安装全部到当前项目
|
|
22
|
+
ea init --lang ts # 仅 TypeScript 规则
|
|
23
|
+
ea init --lang python # 仅 Python 规则
|
|
24
|
+
ea init --lang golang # 仅 Go 规则
|
|
25
|
+
ea status # 查看安装状态
|
|
26
|
+
ea uninstall # 卸载(自动备份)
|
|
27
|
+
ea help # 帮助
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## 与 ECC 的区别
|
|
31
|
+
|
|
32
|
+
| | ECC (Claude Code) | EA (Antigravity) |
|
|
33
|
+
|---|---|---|
|
|
34
|
+
| 安装 | 克隆仓库 + bash | **`npm i -g` + `ea init`** |
|
|
35
|
+
| 路径 | `~/.claude/` | `.agent/` |
|
|
36
|
+
| Hooks | JS hooks 脚本 | **编辑后操作提醒** |
|
|
37
|
+
| Rules | 无 frontmatter | `trigger: glob/model_decision` |
|
|
38
|
+
| 持久记忆 | 无 | **Knowledge Items** |
|
|
39
|
+
| 安全 | 手动 | **Strict/Sandbox Mode** |
|
|
40
|
+
|
|
41
|
+
## 安装了什么
|
|
42
|
+
|
|
43
|
+
### Skills (26)
|
|
44
|
+
TDD · 安全审查 · 编码标准 · 前后端模式 · Python/Django · Go · Spring Boot/JPA · PostgreSQL/ClickHouse · Agent Guides · ⭐ Knowledge Management · ⭐ Security Hardening
|
|
45
|
+
|
|
46
|
+
### Workflows (11)
|
|
47
|
+
`/plan` ⭐ · `/verify` ⭐ · `/tdd` · `/code-review` · `/e2e` · `/build-fix` · `/go-build` · `/go-review` · `/go-test` · `/python-review` · `/setup-pm`
|
|
48
|
+
|
|
49
|
+
### Rules (18)
|
|
50
|
+
6 通用 (`model_decision`) + 4 TypeScript + 4 Python + 4 Go (`glob` 按需激活)
|
|
51
|
+
|
|
52
|
+
## 许可
|
|
53
|
+
|
|
54
|
+
MIT
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: model_decision
|
|
3
|
+
description: Coding style rules: immutability, file organization, naming conventions.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Coding Style
|
|
7
|
+
|
|
8
|
+
## Immutability (CRITICAL)
|
|
9
|
+
|
|
10
|
+
ALWAYS create new objects, NEVER mutate existing ones:
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
// Pseudocode
|
|
14
|
+
WRONG: modify(original, field, value) → changes original in-place
|
|
15
|
+
CORRECT: update(original, field, value) → returns new copy with change
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Rationale: Immutable data prevents hidden side effects, makes debugging easier, and enables safe concurrency.
|
|
19
|
+
|
|
20
|
+
## File Organization
|
|
21
|
+
|
|
22
|
+
MANY SMALL FILES > FEW LARGE FILES:
|
|
23
|
+
- High cohesion, low coupling
|
|
24
|
+
- 200-400 lines typical, 800 max
|
|
25
|
+
- Extract utilities from large modules
|
|
26
|
+
- Organize by feature/domain, not by type
|
|
27
|
+
|
|
28
|
+
## Error Handling
|
|
29
|
+
|
|
30
|
+
ALWAYS handle errors comprehensively:
|
|
31
|
+
- Handle errors explicitly at every level
|
|
32
|
+
- Provide user-friendly error messages in UI-facing code
|
|
33
|
+
- Log detailed error context on the server side
|
|
34
|
+
- Never silently swallow errors
|
|
35
|
+
|
|
36
|
+
## Input Validation
|
|
37
|
+
|
|
38
|
+
ALWAYS validate at system boundaries:
|
|
39
|
+
- Validate all user input before processing
|
|
40
|
+
- Use schema-based validation where available
|
|
41
|
+
- Fail fast with clear error messages
|
|
42
|
+
- Never trust external data (API responses, user input, file content)
|
|
43
|
+
|
|
44
|
+
## Code Quality Checklist
|
|
45
|
+
|
|
46
|
+
Before marking work complete:
|
|
47
|
+
- [ ] Code is readable and well-named
|
|
48
|
+
- [ ] Functions are small (<50 lines)
|
|
49
|
+
- [ ] Files are focused (<800 lines)
|
|
50
|
+
- [ ] No deep nesting (>4 levels)
|
|
51
|
+
- [ ] Proper error handling
|
|
52
|
+
- [ ] No hardcoded values (use constants or config)
|
|
53
|
+
- [ ] No mutation (immutable patterns used)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: model_decision
|
|
3
|
+
description: Git commit message format, branch naming, and PR process.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Git Workflow
|
|
7
|
+
|
|
8
|
+
## Commit Message Format
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
<type>: <description>
|
|
12
|
+
|
|
13
|
+
<optional body>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Types: feat, fix, refactor, docs, test, chore, perf, ci
|
|
17
|
+
|
|
18
|
+
## Pull Request Workflow
|
|
19
|
+
|
|
20
|
+
When creating PRs:
|
|
21
|
+
1. Analyze full commit history (not just latest commit)
|
|
22
|
+
2. Use `git diff [base-branch]...HEAD` to see all changes
|
|
23
|
+
3. Draft comprehensive PR summary
|
|
24
|
+
4. Include test plan with TODOs
|
|
25
|
+
5. Push with `-u` flag if new branch
|
|
26
|
+
|
|
27
|
+
## Feature Implementation Workflow
|
|
28
|
+
|
|
29
|
+
1. **Plan First**
|
|
30
|
+
- Create implementation plan before writing code
|
|
31
|
+
- Identify dependencies and risks
|
|
32
|
+
- Break down into phases
|
|
33
|
+
|
|
34
|
+
2. **TDD Approach**
|
|
35
|
+
- Write tests first (RED)
|
|
36
|
+
- Implement to pass tests (GREEN)
|
|
37
|
+
- Refactor (IMPROVE)
|
|
38
|
+
- Verify 80%+ coverage
|
|
39
|
+
|
|
40
|
+
3. **Code Review**
|
|
41
|
+
- Review code immediately after writing
|
|
42
|
+
- Address CRITICAL and HIGH issues
|
|
43
|
+
- Fix MEDIUM issues when possible
|
|
44
|
+
|
|
45
|
+
4. **Commit & Push**
|
|
46
|
+
- Detailed commit messages
|
|
47
|
+
- Follow conventional commits format
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: model_decision
|
|
3
|
+
description: Design patterns, skeleton projects, and code organization.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Common Patterns
|
|
7
|
+
|
|
8
|
+
## Skeleton Projects
|
|
9
|
+
|
|
10
|
+
When implementing new functionality:
|
|
11
|
+
1. Search for battle-tested skeleton projects
|
|
12
|
+
2. Evaluate options across multiple dimensions:
|
|
13
|
+
- Security assessment
|
|
14
|
+
- Extensibility analysis
|
|
15
|
+
- Relevance scoring
|
|
16
|
+
- Implementation planning
|
|
17
|
+
3. Clone best match as foundation
|
|
18
|
+
4. Iterate within proven structure
|
|
19
|
+
|
|
20
|
+
## Design Patterns
|
|
21
|
+
|
|
22
|
+
### Repository Pattern
|
|
23
|
+
|
|
24
|
+
Encapsulate data access behind a consistent interface:
|
|
25
|
+
- Define standard operations: findAll, findById, create, update, delete
|
|
26
|
+
- Concrete implementations handle storage details (database, API, file, etc.)
|
|
27
|
+
- Business logic depends on the abstract interface, not the storage mechanism
|
|
28
|
+
- Enables easy swapping of data sources and simplifies testing with mocks
|
|
29
|
+
|
|
30
|
+
### API Response Format
|
|
31
|
+
|
|
32
|
+
Use a consistent envelope for all API responses:
|
|
33
|
+
- Include a success/status indicator
|
|
34
|
+
- Include the data payload (nullable on error)
|
|
35
|
+
- Include an error message field (nullable on success)
|
|
36
|
+
- Include metadata for paginated responses (total, page, limit)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: model_decision
|
|
3
|
+
description: Performance optimization, context management, and build troubleshooting.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Performance Optimization
|
|
7
|
+
|
|
8
|
+
## Context Management
|
|
9
|
+
|
|
10
|
+
Keep context window lean to maximize quality:
|
|
11
|
+
- Break large tasks into smaller, focused sub-tasks
|
|
12
|
+
- Avoid loading all files at once; load only relevant code
|
|
13
|
+
- Periodically summarize progress in comments or task lists
|
|
14
|
+
|
|
15
|
+
## Build Troubleshooting
|
|
16
|
+
|
|
17
|
+
If build fails:
|
|
18
|
+
1. Analyze error messages carefully
|
|
19
|
+
2. Fix incrementally (one error at a time)
|
|
20
|
+
3. Verify after each fix
|
|
21
|
+
4. Check for cascading errors that resolve themselves
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: model_decision
|
|
3
|
+
description: Mandatory security checks: authentication, input validation, API security.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Security Guidelines
|
|
7
|
+
|
|
8
|
+
## Mandatory Security Checks
|
|
9
|
+
|
|
10
|
+
Before ANY commit:
|
|
11
|
+
- [ ] No hardcoded secrets (API keys, passwords, tokens)
|
|
12
|
+
- [ ] All user inputs validated
|
|
13
|
+
- [ ] SQL injection prevention (parameterized queries)
|
|
14
|
+
- [ ] XSS prevention (sanitized HTML)
|
|
15
|
+
- [ ] CSRF protection enabled
|
|
16
|
+
- [ ] Authentication/authorization verified
|
|
17
|
+
- [ ] Rate limiting on all endpoints
|
|
18
|
+
- [ ] Error messages don't leak sensitive data
|
|
19
|
+
|
|
20
|
+
## Secret Management
|
|
21
|
+
|
|
22
|
+
- NEVER hardcode secrets in source code
|
|
23
|
+
- ALWAYS use environment variables or a secret manager
|
|
24
|
+
- Validate that required secrets are present at startup
|
|
25
|
+
- Rotate any secrets that may have been exposed
|
|
26
|
+
|
|
27
|
+
## Security Response Protocol
|
|
28
|
+
|
|
29
|
+
If security issue found:
|
|
30
|
+
1. STOP immediately
|
|
31
|
+
2. Conduct thorough security review
|
|
32
|
+
3. Fix CRITICAL issues before continuing
|
|
33
|
+
4. Rotate any exposed secrets
|
|
34
|
+
5. Review entire codebase for similar issues
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: model_decision
|
|
3
|
+
description: Testing requirements: TDD methodology, 80% minimum coverage.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Testing Requirements
|
|
7
|
+
|
|
8
|
+
## Minimum Test Coverage: 80%
|
|
9
|
+
|
|
10
|
+
Test Types (ALL required):
|
|
11
|
+
1. **Unit Tests** - Individual functions, utilities, components
|
|
12
|
+
2. **Integration Tests** - API endpoints, database operations
|
|
13
|
+
3. **E2E Tests** - Critical user flows (framework chosen per language)
|
|
14
|
+
|
|
15
|
+
## Test-Driven Development
|
|
16
|
+
|
|
17
|
+
MANDATORY workflow:
|
|
18
|
+
1. Write test first (RED)
|
|
19
|
+
2. Run test - it should FAIL
|
|
20
|
+
3. Write minimal implementation (GREEN)
|
|
21
|
+
4. Run test - it should PASS
|
|
22
|
+
5. Refactor (IMPROVE)
|
|
23
|
+
6. Verify coverage (80%+)
|
|
24
|
+
|
|
25
|
+
## Troubleshooting Test Failures
|
|
26
|
+
|
|
27
|
+
1. Check test isolation
|
|
28
|
+
2. Verify mocks are correct
|
|
29
|
+
3. Fix implementation, not tests (unless tests are wrong)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: glob
|
|
3
|
+
globs: "**/*.go"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Go Coding Style
|
|
7
|
+
|
|
8
|
+
> Extends common coding-style with Go specific content.
|
|
9
|
+
|
|
10
|
+
## Formatting
|
|
11
|
+
|
|
12
|
+
- **gofmt** and **goimports** are mandatory — no style debates
|
|
13
|
+
|
|
14
|
+
## Design Principles
|
|
15
|
+
|
|
16
|
+
- Accept interfaces, return structs
|
|
17
|
+
- Keep interfaces small (1-3 methods)
|
|
18
|
+
|
|
19
|
+
## Error Handling
|
|
20
|
+
|
|
21
|
+
Always wrap errors with context:
|
|
22
|
+
|
|
23
|
+
```go
|
|
24
|
+
if err != nil {
|
|
25
|
+
return fmt.Errorf("failed to create user: %w", err)
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 编辑后操作(替代 Hooks)
|
|
30
|
+
|
|
31
|
+
编辑 Go 文件后,应主动执行以下检查:
|
|
32
|
+
|
|
33
|
+
1. **格式化**: `gofmt -w {file}` 或 `goimports -w {file}`
|
|
34
|
+
2. **静态分析**: `go vet ./...`
|
|
35
|
+
3. **扩展检查**: `staticcheck ./...`(如已安装)
|
|
36
|
+
4. **检查残留**: 确认没有 `fmt.Println` 调试输出残留
|
|
37
|
+
|
|
38
|
+
## Reference
|
|
39
|
+
|
|
40
|
+
See skill: `golang-patterns` for comprehensive Go idioms and patterns.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: glob
|
|
3
|
+
globs: "**/*.go"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Go Patterns
|
|
7
|
+
|
|
8
|
+
> Extends common patterns with Go specific content.
|
|
9
|
+
|
|
10
|
+
## Functional Options
|
|
11
|
+
|
|
12
|
+
```go
|
|
13
|
+
type Option func(*Server)
|
|
14
|
+
|
|
15
|
+
func WithPort(port int) Option {
|
|
16
|
+
return func(s *Server) { s.port = port }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
func NewServer(opts ...Option) *Server {
|
|
20
|
+
s := &Server{port: 8080}
|
|
21
|
+
for _, opt := range opts {
|
|
22
|
+
opt(s)
|
|
23
|
+
}
|
|
24
|
+
return s
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Small Interfaces
|
|
29
|
+
|
|
30
|
+
Define interfaces where they are used, not where they are implemented.
|
|
31
|
+
|
|
32
|
+
## Dependency Injection
|
|
33
|
+
|
|
34
|
+
Use constructor functions to inject dependencies:
|
|
35
|
+
|
|
36
|
+
```go
|
|
37
|
+
func NewUserService(repo UserRepository, logger Logger) *UserService {
|
|
38
|
+
return &UserService{repo: repo, logger: logger}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Reference
|
|
43
|
+
|
|
44
|
+
See skill: `golang-patterns` for comprehensive Go patterns including concurrency, error handling, and package organization.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: glob
|
|
3
|
+
globs: "**/*.go"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Go Security
|
|
7
|
+
|
|
8
|
+
> Extends common security with Go specific content.
|
|
9
|
+
|
|
10
|
+
## Secret Management
|
|
11
|
+
|
|
12
|
+
```go
|
|
13
|
+
apiKey := os.Getenv("OPENAI_API_KEY")
|
|
14
|
+
if apiKey == "" {
|
|
15
|
+
log.Fatal("OPENAI_API_KEY not configured")
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Security Scanning
|
|
20
|
+
|
|
21
|
+
- Use **gosec** for static security analysis:
|
|
22
|
+
```bash
|
|
23
|
+
gosec ./...
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Context & Timeouts
|
|
27
|
+
|
|
28
|
+
Always use `context.Context` for timeout control:
|
|
29
|
+
|
|
30
|
+
```go
|
|
31
|
+
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
|
32
|
+
defer cancel()
|
|
33
|
+
```
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: glob
|
|
3
|
+
globs: "**/*.go"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Go Testing
|
|
7
|
+
|
|
8
|
+
> Extends common testing with Go specific content.
|
|
9
|
+
|
|
10
|
+
## Framework
|
|
11
|
+
|
|
12
|
+
Use the standard `go test` with **table-driven tests**.
|
|
13
|
+
|
|
14
|
+
## Race Detection
|
|
15
|
+
|
|
16
|
+
Always run with the `-race` flag:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
go test -race ./...
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Coverage
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
go test -cover ./...
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Reference
|
|
29
|
+
|
|
30
|
+
See skill: `golang-testing` for detailed Go testing patterns and helpers.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: glob
|
|
3
|
+
globs: "**/*.py, **/*.pyi"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Python Coding Style
|
|
7
|
+
|
|
8
|
+
> Extends common coding-style 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
|
+
## 编辑后操作(替代 Hooks)
|
|
41
|
+
|
|
42
|
+
编辑 Python 文件后,应主动执行以下检查:
|
|
43
|
+
|
|
44
|
+
1. **格式化**: `black {file}`
|
|
45
|
+
2. **Lint**: `ruff check {file} --fix`
|
|
46
|
+
3. **Import 排序**: `isort {file}`
|
|
47
|
+
4. **类型检查**: `mypy {file}`(如果项目使用 mypy)
|
|
48
|
+
5. **检查残留**: 确认没有 `print()` 残留(应使用 `logging` 模块)
|
|
49
|
+
|
|
50
|
+
## Reference
|
|
51
|
+
|
|
52
|
+
See skill: `python-patterns` for comprehensive Python idioms and patterns.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: glob
|
|
3
|
+
globs: "**/*.py, **/*.pyi"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Python Patterns
|
|
7
|
+
|
|
8
|
+
> Extends common patterns 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.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: glob
|
|
3
|
+
globs: "**/*.py, **/*.pyi"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Python Security
|
|
7
|
+
|
|
8
|
+
> Extends common security 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).
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: glob
|
|
3
|
+
globs: "**/*.py, **/*.pyi"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Python Testing
|
|
7
|
+
|
|
8
|
+
> Extends common testing 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.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
trigger: glob
|
|
3
|
+
globs: "**/*.ts, **/*.tsx, **/*.js, **/*.jsx"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# TypeScript/JavaScript Coding Style
|
|
7
|
+
|
|
8
|
+
> Extends common coding-style with TypeScript/JavaScript specific content.
|
|
9
|
+
|
|
10
|
+
## Standards
|
|
11
|
+
|
|
12
|
+
- Use **strict mode** TypeScript (`strict: true` in tsconfig)
|
|
13
|
+
- Prefer `const` over `let`, avoid `var`
|
|
14
|
+
- Use template literals over string concatenation
|
|
15
|
+
|
|
16
|
+
## Immutability
|
|
17
|
+
|
|
18
|
+
Use `readonly` and `Readonly<T>` for immutable data:
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
interface User {
|
|
22
|
+
readonly id: string
|
|
23
|
+
readonly name: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function updateUser(user: Readonly<User>, changes: Partial<User>): User {
|
|
27
|
+
return { ...user, ...changes }
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Formatting
|
|
32
|
+
|
|
33
|
+
- **Prettier** for code formatting
|
|
34
|
+
- **ESLint** for linting
|
|
35
|
+
- Consistent import ordering (external → internal → relative)
|
|
36
|
+
|
|
37
|
+
## 编辑后操作(替代 Hooks)
|
|
38
|
+
|
|
39
|
+
编辑 TypeScript/JavaScript 文件后,应主动执行以下检查:
|
|
40
|
+
|
|
41
|
+
1. **格式化**: `npx prettier --write {file}`
|
|
42
|
+
2. **类型检查**: `npx tsc --noEmit`(仅 `.ts`/`.tsx` 文件)
|
|
43
|
+
3. **Lint**: `npx eslint {file}`
|
|
44
|
+
4. **检查残留**: 确认没有 `console.log` 残留在生产代码中
|