oh-my-customcode 0.7.0 → 0.9.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/README.md +38 -12
- package/dist/cli/index.js +518 -274
- package/dist/index.js +304 -101
- package/package.json +1 -1
- package/templates/.claude/agents/db-postgres-expert.md +106 -0
- package/templates/.claude/agents/db-redis-expert.md +101 -0
- package/templates/.claude/agents/de-airflow-expert.md +71 -0
- package/templates/.claude/agents/de-dbt-expert.md +72 -0
- package/templates/.claude/agents/de-kafka-expert.md +81 -0
- package/templates/.claude/agents/de-pipeline-expert.md +92 -0
- package/templates/.claude/agents/de-snowflake-expert.md +89 -0
- package/templates/.claude/agents/de-spark-expert.md +80 -0
- package/templates/.claude/rules/SHOULD-agent-teams.md +47 -1
- package/templates/.claude/skills/airflow-best-practices/SKILL.md +56 -0
- package/templates/.claude/skills/dbt-best-practices/SKILL.md +54 -0
- package/templates/.claude/skills/de-lead-routing/SKILL.md +230 -0
- package/templates/.claude/skills/dev-lead-routing/SKILL.md +15 -0
- package/templates/.claude/skills/kafka-best-practices/SKILL.md +52 -0
- package/templates/.claude/skills/pipeline-architecture-patterns/SKILL.md +83 -0
- package/templates/.claude/skills/postgres-best-practices/SKILL.md +66 -0
- package/templates/.claude/skills/redis-best-practices/SKILL.md +83 -0
- package/templates/.claude/skills/secretary-routing/SKILL.md +12 -0
- package/templates/.claude/skills/snowflake-best-practices/SKILL.md +65 -0
- package/templates/.claude/skills/spark-best-practices/SKILL.md +52 -0
- package/templates/.codex/agents/arch-documenter.md +97 -0
- package/templates/.codex/agents/arch-speckit-agent.md +134 -0
- package/templates/.codex/agents/be-express-expert.md +80 -0
- package/templates/.codex/agents/be-fastapi-expert.md +43 -0
- package/templates/.codex/agents/be-go-backend-expert.md +43 -0
- package/templates/.codex/agents/be-nestjs-expert.md +60 -0
- package/templates/.codex/agents/be-springboot-expert.md +85 -0
- package/templates/.codex/agents/db-postgres-expert.md +106 -0
- package/templates/.codex/agents/db-redis-expert.md +101 -0
- package/templates/.codex/agents/db-supabase-expert.md +71 -0
- package/templates/.codex/agents/de-airflow-expert.md +71 -0
- package/templates/.codex/agents/de-dbt-expert.md +72 -0
- package/templates/.codex/agents/de-kafka-expert.md +81 -0
- package/templates/.codex/agents/de-pipeline-expert.md +92 -0
- package/templates/.codex/agents/de-snowflake-expert.md +89 -0
- package/templates/.codex/agents/de-spark-expert.md +80 -0
- package/templates/.codex/agents/fe-svelte-agent.md +65 -0
- package/templates/.codex/agents/fe-vercel-agent.md +69 -0
- package/templates/.codex/agents/fe-vuejs-agent.md +65 -0
- package/templates/.codex/agents/infra-aws-expert.md +47 -0
- package/templates/.codex/agents/infra-docker-expert.md +47 -0
- package/templates/.codex/agents/lang-golang-expert.md +43 -0
- package/templates/.codex/agents/lang-java21-expert.md +65 -0
- package/templates/.codex/agents/lang-kotlin-expert.md +43 -0
- package/templates/.codex/agents/lang-python-expert.md +43 -0
- package/templates/.codex/agents/lang-rust-expert.md +43 -0
- package/templates/.codex/agents/lang-typescript-expert.md +43 -0
- package/templates/.codex/agents/mgr-claude-code-bible.md +246 -0
- package/templates/.codex/agents/mgr-creator.md +120 -0
- package/templates/.codex/agents/mgr-gitnerd.md +113 -0
- package/templates/.codex/agents/mgr-sauron.md +154 -0
- package/templates/.codex/agents/mgr-supplier.md +120 -0
- package/templates/.codex/agents/mgr-sync-checker.md +99 -0
- package/templates/.codex/agents/mgr-updater.md +103 -0
- package/templates/.codex/agents/qa-engineer.md +96 -0
- package/templates/.codex/agents/qa-planner.md +74 -0
- package/templates/.codex/agents/qa-writer.md +97 -0
- package/templates/.codex/agents/sys-memory-keeper.md +117 -0
- package/templates/.codex/agents/sys-naggy.md +90 -0
- package/templates/.codex/agents/tool-bun-expert.md +71 -0
- package/templates/.codex/agents/tool-npm-expert.md +88 -0
- package/templates/.codex/agents/tool-optimizer.md +87 -0
- package/templates/.codex/codex-native-hash.txt +1 -0
- package/templates/.codex/contexts/dev.md +20 -0
- package/templates/.codex/contexts/ecomode.md +63 -0
- package/templates/.codex/contexts/index.yaml +41 -0
- package/templates/.codex/contexts/research.md +28 -0
- package/templates/.codex/contexts/review.md +23 -0
- package/templates/.codex/hooks/hooks.json +151 -0
- package/templates/.codex/install-hooks.sh +100 -0
- package/templates/.codex/rules/MAY-optimization.md +93 -0
- package/templates/.codex/rules/MUST-agent-design.md +162 -0
- package/templates/.codex/rules/MUST-agent-identification.md +108 -0
- package/templates/.codex/rules/MUST-continuous-improvement.md +132 -0
- package/templates/.codex/rules/MUST-intent-transparency.md +199 -0
- package/templates/.codex/rules/MUST-language-policy.md +62 -0
- package/templates/.codex/rules/MUST-orchestrator-coordination.md +471 -0
- package/templates/.codex/rules/MUST-parallel-execution.md +469 -0
- package/templates/.codex/rules/MUST-permissions.md +84 -0
- package/templates/.codex/rules/MUST-safety.md +69 -0
- package/templates/.codex/rules/MUST-sync-verification.md +281 -0
- package/templates/.codex/rules/MUST-tool-identification.md +195 -0
- package/templates/.codex/rules/SHOULD-agent-teams.md +183 -0
- package/templates/.codex/rules/SHOULD-ecomode.md +145 -0
- package/templates/.codex/rules/SHOULD-error-handling.md +102 -0
- package/templates/.codex/rules/SHOULD-hud-statusline.md +112 -0
- package/templates/.codex/rules/SHOULD-interaction.md +103 -0
- package/templates/.codex/rules/SHOULD-memory-integration.md +132 -0
- package/templates/.codex/rules/index.yaml +141 -0
- package/templates/.codex/skills/airflow-best-practices/SKILL.md +56 -0
- package/templates/.codex/skills/audit-agents/SKILL.md +116 -0
- package/templates/.codex/skills/aws-best-practices/SKILL.md +280 -0
- package/templates/.codex/skills/claude-code-bible/SKILL.md +180 -0
- package/templates/.codex/skills/claude-code-bible/scripts/fetch-docs.js +244 -0
- package/templates/.codex/skills/create-agent/SKILL.md +91 -0
- package/templates/.codex/skills/dbt-best-practices/SKILL.md +54 -0
- package/templates/.codex/skills/de-lead-routing/SKILL.md +230 -0
- package/templates/.codex/skills/dev-lead-routing/SKILL.md +253 -0
- package/templates/.codex/skills/dev-refactor/SKILL.md +123 -0
- package/templates/.codex/skills/dev-review/SKILL.md +81 -0
- package/templates/.codex/skills/docker-best-practices/SKILL.md +275 -0
- package/templates/.codex/skills/fastapi-best-practices/SKILL.md +270 -0
- package/templates/.codex/skills/fix-refs/SKILL.md +107 -0
- package/templates/.codex/skills/go-backend-best-practices/SKILL.md +338 -0
- package/templates/.codex/skills/go-best-practices/CLAUDE.md +9 -0
- package/templates/.codex/skills/go-best-practices/SKILL.md +203 -0
- package/templates/.codex/skills/help/SKILL.md +125 -0
- package/templates/.codex/skills/intent-detection/SKILL.md +215 -0
- package/templates/.codex/skills/intent-detection/patterns/agent-triggers.yaml +349 -0
- package/templates/.codex/skills/kafka-best-practices/SKILL.md +52 -0
- package/templates/.codex/skills/kotlin-best-practices/SKILL.md +256 -0
- package/templates/.codex/skills/lists/SKILL.md +78 -0
- package/templates/.codex/skills/memory-management/SKILL.md +195 -0
- package/templates/.codex/skills/memory-recall/SKILL.md +152 -0
- package/templates/.codex/skills/memory-save/SKILL.md +126 -0
- package/templates/.codex/skills/monitoring-setup/SKILL.md +115 -0
- package/templates/.codex/skills/npm-audit/SKILL.md +72 -0
- package/templates/.codex/skills/npm-publish/SKILL.md +63 -0
- package/templates/.codex/skills/npm-version/SKILL.md +75 -0
- package/templates/.codex/skills/optimize-analyze/SKILL.md +55 -0
- package/templates/.codex/skills/optimize-bundle/SKILL.md +67 -0
- package/templates/.codex/skills/optimize-report/SKILL.md +74 -0
- package/templates/.codex/skills/pipeline-architecture-patterns/SKILL.md +83 -0
- package/templates/.codex/skills/postgres-best-practices/SKILL.md +66 -0
- package/templates/.codex/skills/python-best-practices/SKILL.md +222 -0
- package/templates/.codex/skills/qa-lead-routing/SKILL.md +277 -0
- package/templates/.codex/skills/react-best-practices/SKILL.md +101 -0
- package/templates/.codex/skills/redis-best-practices/SKILL.md +83 -0
- package/templates/.codex/skills/result-aggregation/SKILL.md +164 -0
- package/templates/.codex/skills/rust-best-practices/SKILL.md +267 -0
- package/templates/.codex/skills/sauron-watch/SKILL.md +144 -0
- package/templates/.codex/skills/secretary-routing/SKILL.md +190 -0
- package/templates/.codex/skills/snowflake-best-practices/SKILL.md +65 -0
- package/templates/.codex/skills/spark-best-practices/SKILL.md +52 -0
- package/templates/.codex/skills/springboot-best-practices/SKILL.md +357 -0
- package/templates/.codex/skills/status/SKILL.md +153 -0
- package/templates/.codex/skills/supabase-postgres-best-practices/SKILL.md +99 -0
- package/templates/.codex/skills/typescript-best-practices/SKILL.md +321 -0
- package/templates/.codex/skills/update-docs/SKILL.md +140 -0
- package/templates/.codex/skills/update-external/SKILL.md +149 -0
- package/templates/.codex/skills/vercel-deploy/SKILL.md +73 -0
- package/templates/.codex/skills/web-design-guidelines/SKILL.md +118 -0
- package/templates/.codex/skills/writing-clearly-and-concisely/SKILL.md +64 -0
- package/templates/.codex/uninstall-hooks.sh +52 -0
- package/templates/AGENTS.md.en +39 -0
- package/templates/AGENTS.md.ko +39 -0
- package/templates/CLAUDE.md.en +7 -5
- package/templates/CLAUDE.md.ko +7 -5
- package/templates/guides/airflow/README.md +32 -0
- package/templates/guides/dbt/README.md +32 -0
- package/templates/guides/iceberg/README.md +49 -0
- package/templates/guides/kafka/README.md +32 -0
- package/templates/guides/postgres/README.md +58 -0
- package/templates/guides/redis/README.md +50 -0
- package/templates/guides/snowflake/README.md +32 -0
- package/templates/guides/spark/README.md +32 -0
- package/templates/manifest.codex.json +43 -0
- package/templates/manifest.json +5 -5
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: go-backend-best-practices
|
|
3
|
+
description: Go backend patterns from Uber style and standard layout
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Purpose
|
|
8
|
+
|
|
9
|
+
Apply Go backend patterns for building production-ready services.
|
|
10
|
+
|
|
11
|
+
## Rules
|
|
12
|
+
|
|
13
|
+
### 1. Project Structure (Standard Layout)
|
|
14
|
+
|
|
15
|
+
```yaml
|
|
16
|
+
layout: |
|
|
17
|
+
project/
|
|
18
|
+
├── cmd/
|
|
19
|
+
│ └── server/
|
|
20
|
+
│ └── main.go
|
|
21
|
+
├── internal/
|
|
22
|
+
│ ├── handler/
|
|
23
|
+
│ ├── service/
|
|
24
|
+
│ ├── repository/
|
|
25
|
+
│ └── model/
|
|
26
|
+
├── pkg/
|
|
27
|
+
│ └── shared/
|
|
28
|
+
├── api/
|
|
29
|
+
│ └── openapi.yaml
|
|
30
|
+
├── configs/
|
|
31
|
+
├── scripts/
|
|
32
|
+
├── Dockerfile
|
|
33
|
+
├── Makefile
|
|
34
|
+
└── go.mod
|
|
35
|
+
|
|
36
|
+
directories:
|
|
37
|
+
cmd: Main applications (one per binary)
|
|
38
|
+
internal: Private application code
|
|
39
|
+
pkg: Library code safe for external use
|
|
40
|
+
api: API definitions (OpenAPI, protobuf)
|
|
41
|
+
configs: Configuration files
|
|
42
|
+
scripts: Build and CI scripts
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 2. Error Handling (Uber Style)
|
|
46
|
+
|
|
47
|
+
```yaml
|
|
48
|
+
principles:
|
|
49
|
+
- Wrap errors with context using %w
|
|
50
|
+
- Handle errors once (don't log AND return)
|
|
51
|
+
- Use sentinel errors for specific conditions
|
|
52
|
+
- Name error variables with Err prefix
|
|
53
|
+
|
|
54
|
+
patterns: |
|
|
55
|
+
// Sentinel errors
|
|
56
|
+
var (
|
|
57
|
+
ErrNotFound = errors.New("not found")
|
|
58
|
+
ErrInvalidInput = errors.New("invalid input")
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
// Wrap with context
|
|
62
|
+
func getUser(id string) (*User, error) {
|
|
63
|
+
user, err := db.FindUser(id)
|
|
64
|
+
if err != nil {
|
|
65
|
+
return nil, fmt.Errorf("getUser %s: %w", id, err)
|
|
66
|
+
}
|
|
67
|
+
return user, nil
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Check specific errors
|
|
71
|
+
if errors.Is(err, ErrNotFound) {
|
|
72
|
+
return http.StatusNotFound
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 3. Concurrency (Uber Style)
|
|
77
|
+
|
|
78
|
+
```yaml
|
|
79
|
+
channels:
|
|
80
|
+
size: "Use 0 (unbuffered) or 1 only"
|
|
81
|
+
larger: "Requires careful review"
|
|
82
|
+
|
|
83
|
+
goroutines:
|
|
84
|
+
never: fire-and-forget
|
|
85
|
+
always: wait for completion or manage lifecycle
|
|
86
|
+
|
|
87
|
+
patterns: |
|
|
88
|
+
// Wait group for goroutines
|
|
89
|
+
func process(items []Item) error {
|
|
90
|
+
var wg sync.WaitGroup
|
|
91
|
+
errCh := make(chan error, 1)
|
|
92
|
+
|
|
93
|
+
for _, item := range items {
|
|
94
|
+
wg.Add(1)
|
|
95
|
+
go func(item Item) {
|
|
96
|
+
defer wg.Done()
|
|
97
|
+
if err := processItem(item); err != nil {
|
|
98
|
+
select {
|
|
99
|
+
case errCh <- err:
|
|
100
|
+
default:
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}(item)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
wg.Wait()
|
|
107
|
+
close(errCh)
|
|
108
|
+
return <-errCh
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Context for cancellation
|
|
112
|
+
func longRunningTask(ctx context.Context) error {
|
|
113
|
+
for {
|
|
114
|
+
select {
|
|
115
|
+
case <-ctx.Done():
|
|
116
|
+
return ctx.Err()
|
|
117
|
+
default:
|
|
118
|
+
// do work
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 4. HTTP Server
|
|
125
|
+
|
|
126
|
+
```yaml
|
|
127
|
+
structure:
|
|
128
|
+
handler: HTTP layer (request/response)
|
|
129
|
+
service: Business logic
|
|
130
|
+
repository: Data access
|
|
131
|
+
|
|
132
|
+
patterns: |
|
|
133
|
+
// Handler with dependency injection
|
|
134
|
+
type UserHandler struct {
|
|
135
|
+
service UserService
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
func NewUserHandler(s UserService) *UserHandler {
|
|
139
|
+
return &UserHandler{service: s}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
func (h *UserHandler) GetUser(w http.ResponseWriter, r *http.Request) {
|
|
143
|
+
id := chi.URLParam(r, "id")
|
|
144
|
+
|
|
145
|
+
user, err := h.service.GetUser(r.Context(), id)
|
|
146
|
+
if err != nil {
|
|
147
|
+
if errors.Is(err, ErrNotFound) {
|
|
148
|
+
http.Error(w, "user not found", http.StatusNotFound)
|
|
149
|
+
return
|
|
150
|
+
}
|
|
151
|
+
http.Error(w, "internal error", http.StatusInternalServerError)
|
|
152
|
+
return
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
json.NewEncoder(w).Encode(user)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Router setup
|
|
159
|
+
func NewRouter(h *UserHandler) *chi.Mux {
|
|
160
|
+
r := chi.NewRouter()
|
|
161
|
+
r.Use(middleware.Logger)
|
|
162
|
+
r.Use(middleware.Recoverer)
|
|
163
|
+
|
|
164
|
+
r.Route("/api/v1", func(r chi.Router) {
|
|
165
|
+
r.Get("/users/{id}", h.GetUser)
|
|
166
|
+
r.Post("/users", h.CreateUser)
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
return r
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### 5. Dependency Injection
|
|
174
|
+
|
|
175
|
+
```yaml
|
|
176
|
+
approach: constructor injection
|
|
177
|
+
avoid: global variables
|
|
178
|
+
|
|
179
|
+
patterns: |
|
|
180
|
+
// Service with dependencies
|
|
181
|
+
type UserService struct {
|
|
182
|
+
repo UserRepository
|
|
183
|
+
cache Cache
|
|
184
|
+
logger *slog.Logger
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
func NewUserService(
|
|
188
|
+
repo UserRepository,
|
|
189
|
+
cache Cache,
|
|
190
|
+
logger *slog.Logger,
|
|
191
|
+
) *UserService {
|
|
192
|
+
return &UserService{
|
|
193
|
+
repo: repo,
|
|
194
|
+
cache: cache,
|
|
195
|
+
logger: logger,
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Wire up in main
|
|
200
|
+
func main() {
|
|
201
|
+
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
|
|
202
|
+
db := database.New(cfg.DatabaseURL)
|
|
203
|
+
cache := redis.New(cfg.RedisURL)
|
|
204
|
+
|
|
205
|
+
repo := repository.NewUserRepository(db)
|
|
206
|
+
service := service.NewUserService(repo, cache, logger)
|
|
207
|
+
handler := handler.NewUserHandler(service)
|
|
208
|
+
|
|
209
|
+
router := handler.NewRouter(handler)
|
|
210
|
+
http.ListenAndServe(":8080", router)
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### 6. Configuration
|
|
215
|
+
|
|
216
|
+
```yaml
|
|
217
|
+
approach:
|
|
218
|
+
- Use environment variables
|
|
219
|
+
- Validate at startup
|
|
220
|
+
- Group related settings
|
|
221
|
+
|
|
222
|
+
patterns: |
|
|
223
|
+
type Config struct {
|
|
224
|
+
Server ServerConfig
|
|
225
|
+
Database DatabaseConfig
|
|
226
|
+
Redis RedisConfig
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
type ServerConfig struct {
|
|
230
|
+
Host string `env:"SERVER_HOST" envDefault:"0.0.0.0"`
|
|
231
|
+
Port int `env:"SERVER_PORT" envDefault:"8080"`
|
|
232
|
+
ReadTimeout time.Duration `env:"SERVER_READ_TIMEOUT" envDefault:"5s"`
|
|
233
|
+
WriteTimeout time.Duration `env:"SERVER_WRITE_TIMEOUT" envDefault:"10s"`
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
func LoadConfig() (*Config, error) {
|
|
237
|
+
var cfg Config
|
|
238
|
+
if err := env.Parse(&cfg); err != nil {
|
|
239
|
+
return nil, fmt.Errorf("parse config: %w", err)
|
|
240
|
+
}
|
|
241
|
+
return &cfg, nil
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### 7. Testing
|
|
246
|
+
|
|
247
|
+
```yaml
|
|
248
|
+
patterns:
|
|
249
|
+
table_driven: for comprehensive coverage
|
|
250
|
+
interfaces: for mocking
|
|
251
|
+
parallel: for speed
|
|
252
|
+
|
|
253
|
+
example: |
|
|
254
|
+
func TestUserService_GetUser(t *testing.T) {
|
|
255
|
+
tests := []struct {
|
|
256
|
+
name string
|
|
257
|
+
userID string
|
|
258
|
+
mock func(*MockRepository)
|
|
259
|
+
want *User
|
|
260
|
+
wantErr error
|
|
261
|
+
}{
|
|
262
|
+
{
|
|
263
|
+
name: "success",
|
|
264
|
+
userID: "123",
|
|
265
|
+
mock: func(m *MockRepository) {
|
|
266
|
+
m.EXPECT().FindByID("123").Return(&User{ID: "123"}, nil)
|
|
267
|
+
},
|
|
268
|
+
want: &User{ID: "123"},
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
name: "not found",
|
|
272
|
+
userID: "999",
|
|
273
|
+
mock: func(m *MockRepository) {
|
|
274
|
+
m.EXPECT().FindByID("999").Return(nil, ErrNotFound)
|
|
275
|
+
},
|
|
276
|
+
wantErr: ErrNotFound,
|
|
277
|
+
},
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
for _, tt := range tests {
|
|
281
|
+
t.Run(tt.name, func(t *testing.T) {
|
|
282
|
+
t.Parallel()
|
|
283
|
+
ctrl := gomock.NewController(t)
|
|
284
|
+
repo := NewMockRepository(ctrl)
|
|
285
|
+
tt.mock(repo)
|
|
286
|
+
|
|
287
|
+
svc := NewUserService(repo, nil, slog.Default())
|
|
288
|
+
got, err := svc.GetUser(context.Background(), tt.userID)
|
|
289
|
+
|
|
290
|
+
if !errors.Is(err, tt.wantErr) {
|
|
291
|
+
t.Errorf("got error %v, want %v", err, tt.wantErr)
|
|
292
|
+
}
|
|
293
|
+
if diff := cmp.Diff(tt.want, got); diff != "" {
|
|
294
|
+
t.Errorf("mismatch (-want +got):\n%s", diff)
|
|
295
|
+
}
|
|
296
|
+
})
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### 8. Performance (Uber Style)
|
|
302
|
+
|
|
303
|
+
```yaml
|
|
304
|
+
guidelines:
|
|
305
|
+
- Use strconv over fmt for conversions
|
|
306
|
+
- Pre-allocate slices with known capacity
|
|
307
|
+
- Avoid repeated string-to-byte conversions
|
|
308
|
+
- Copy slices/maps at boundaries
|
|
309
|
+
|
|
310
|
+
patterns: |
|
|
311
|
+
// Pre-allocate
|
|
312
|
+
items := make([]Item, 0, len(input))
|
|
313
|
+
|
|
314
|
+
// strconv for conversions
|
|
315
|
+
s := strconv.Itoa(n) // not fmt.Sprintf("%d", n)
|
|
316
|
+
|
|
317
|
+
// Copy at boundaries
|
|
318
|
+
func (s *Store) GetItems() []Item {
|
|
319
|
+
s.mu.RLock()
|
|
320
|
+
defer s.mu.RUnlock()
|
|
321
|
+
items := make([]Item, len(s.items))
|
|
322
|
+
copy(items, s.items)
|
|
323
|
+
return items
|
|
324
|
+
}
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
## Application
|
|
328
|
+
|
|
329
|
+
When writing Go backend code:
|
|
330
|
+
|
|
331
|
+
1. **Always** use standard project layout
|
|
332
|
+
2. **Always** wrap errors with context
|
|
333
|
+
3. **Never** fire-and-forget goroutines
|
|
334
|
+
4. **Use** constructor injection
|
|
335
|
+
5. **Use** table-driven tests
|
|
336
|
+
6. **Handle** errors once
|
|
337
|
+
7. **Copy** data at boundaries
|
|
338
|
+
8. **Validate** config at startup
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: go-best-practices
|
|
3
|
+
description: Idiomatic Go patterns from Effective Go
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Purpose
|
|
8
|
+
|
|
9
|
+
Apply idiomatic Go patterns and best practices from official Go documentation.
|
|
10
|
+
|
|
11
|
+
## Rules
|
|
12
|
+
|
|
13
|
+
### 1. Formatting
|
|
14
|
+
|
|
15
|
+
```yaml
|
|
16
|
+
rules:
|
|
17
|
+
- Use gofmt for all code formatting
|
|
18
|
+
- Indentation uses tabs, not spaces
|
|
19
|
+
- No line length limit, but break long lines sensibly
|
|
20
|
+
- Let gofmt handle alignment
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### 2. Naming Conventions
|
|
24
|
+
|
|
25
|
+
```yaml
|
|
26
|
+
package_names:
|
|
27
|
+
- Short, concise, lowercase, single-word
|
|
28
|
+
- No underscores or mixedCaps
|
|
29
|
+
- Name is basename of source directory
|
|
30
|
+
- Example: bufio, not bufIO or buf_io
|
|
31
|
+
|
|
32
|
+
getters:
|
|
33
|
+
- No "Get" prefix for getters
|
|
34
|
+
- obj.Owner() not obj.GetOwner()
|
|
35
|
+
- Setter can use "Set": obj.SetOwner(user)
|
|
36
|
+
|
|
37
|
+
interface_names:
|
|
38
|
+
- One-method interfaces: method name + "er"
|
|
39
|
+
- Reader, Writer, Formatter, CloseNotifier
|
|
40
|
+
- Avoid stealing standard names unless same signature
|
|
41
|
+
|
|
42
|
+
mixedCaps:
|
|
43
|
+
- Use MixedCaps or mixedCaps, never underscores
|
|
44
|
+
- Exported: MixedCaps (uppercase first)
|
|
45
|
+
- Unexported: mixedCaps (lowercase first)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 3. Control Structures
|
|
49
|
+
|
|
50
|
+
```yaml
|
|
51
|
+
if_statements:
|
|
52
|
+
- Accept initialization statement
|
|
53
|
+
- Prefer: if err := file.Chmod(0664); err != nil
|
|
54
|
+
- Omit else when if ends with break/continue/return
|
|
55
|
+
- Avoid unnecessary else
|
|
56
|
+
|
|
57
|
+
for_loops:
|
|
58
|
+
- Go's only loop construct
|
|
59
|
+
- for init; condition; post { } - like C for
|
|
60
|
+
- for condition { } - like C while
|
|
61
|
+
- for { } - infinite loop
|
|
62
|
+
- Use range for strings, slices, arrays, maps, channels
|
|
63
|
+
|
|
64
|
+
switch:
|
|
65
|
+
- Cases don't fall through by default
|
|
66
|
+
- Use fallthrough keyword if needed
|
|
67
|
+
- Multiple cases: case '0', '1', '2'
|
|
68
|
+
- Type switch: switch v := x.(type)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 4. Functions
|
|
72
|
+
|
|
73
|
+
```yaml
|
|
74
|
+
multiple_returns:
|
|
75
|
+
- Return multiple values for result + error
|
|
76
|
+
- func (file *File) Write(b []byte) (n int, err error)
|
|
77
|
+
|
|
78
|
+
named_results:
|
|
79
|
+
- Document return values with names
|
|
80
|
+
- Can simplify code but use judiciously
|
|
81
|
+
- Unnamed returns OK for short functions
|
|
82
|
+
|
|
83
|
+
defer:
|
|
84
|
+
- Executes when function returns
|
|
85
|
+
- LIFO order for multiple defers
|
|
86
|
+
- Use for cleanup: unlock mutexes, close files
|
|
87
|
+
- Arguments evaluated when defer executes, not when called
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 5. Data
|
|
91
|
+
|
|
92
|
+
```yaml
|
|
93
|
+
new_vs_make:
|
|
94
|
+
- new(T): allocates zeroed storage, returns *T
|
|
95
|
+
- make(T, args): creates slices, maps, channels only
|
|
96
|
+
- make returns initialized (not zeroed) value of type T
|
|
97
|
+
|
|
98
|
+
slices:
|
|
99
|
+
- Backed by arrays, can grow
|
|
100
|
+
- append() to add elements
|
|
101
|
+
- copy() for safe duplication
|
|
102
|
+
- Slice of slice shares underlying array
|
|
103
|
+
|
|
104
|
+
maps:
|
|
105
|
+
- Reference type, nil until initialized
|
|
106
|
+
- make(map[KeyType]ValueType)
|
|
107
|
+
- Comma ok idiom: val, ok := map[key]
|
|
108
|
+
- delete(map, key) to remove
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### 6. Methods
|
|
112
|
+
|
|
113
|
+
```yaml
|
|
114
|
+
pointer_vs_value_receivers:
|
|
115
|
+
- Pointer receiver: can modify, no copy overhead
|
|
116
|
+
- Value receiver: safe from modification
|
|
117
|
+
- If any method needs pointer, all should use pointer
|
|
118
|
+
- Rule: values immutable, pointers mutable
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### 7. Interfaces
|
|
122
|
+
|
|
123
|
+
```yaml
|
|
124
|
+
design:
|
|
125
|
+
- Interfaces define behavior, not data
|
|
126
|
+
- Small interfaces (1-3 methods) preferred
|
|
127
|
+
- Accept interfaces, return structs
|
|
128
|
+
- If type implements interface, it satisfies implicitly
|
|
129
|
+
|
|
130
|
+
common_interfaces:
|
|
131
|
+
- io.Reader: Read(p []byte) (n int, err error)
|
|
132
|
+
- io.Writer: Write(p []byte) (n int, err error)
|
|
133
|
+
- fmt.Stringer: String() string
|
|
134
|
+
- error: Error() string
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### 8. Concurrency
|
|
138
|
+
|
|
139
|
+
```yaml
|
|
140
|
+
goroutines:
|
|
141
|
+
- Lightweight, multiplexed onto OS threads
|
|
142
|
+
- go function() to start
|
|
143
|
+
- Don't communicate by sharing memory
|
|
144
|
+
- Share memory by communicating
|
|
145
|
+
|
|
146
|
+
channels:
|
|
147
|
+
- Primary synchronization mechanism
|
|
148
|
+
- ch := make(chan int) - unbuffered
|
|
149
|
+
- ch := make(chan int, 100) - buffered
|
|
150
|
+
- Send: ch <- v
|
|
151
|
+
- Receive: v := <-ch
|
|
152
|
+
- Close: close(ch)
|
|
153
|
+
|
|
154
|
+
patterns:
|
|
155
|
+
- Don't leak goroutines - ensure they exit
|
|
156
|
+
- Use context for cancellation
|
|
157
|
+
- select for multiple channel operations
|
|
158
|
+
- sync.WaitGroup for goroutine coordination
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### 9. Error Handling
|
|
162
|
+
|
|
163
|
+
```yaml
|
|
164
|
+
principles:
|
|
165
|
+
- Errors are values, handle them explicitly
|
|
166
|
+
- Check errors immediately after call
|
|
167
|
+
- Return errors, don't panic
|
|
168
|
+
- Add context when propagating: fmt.Errorf("op failed: %w", err)
|
|
169
|
+
|
|
170
|
+
panic_recover:
|
|
171
|
+
- Panic for unrecoverable errors only
|
|
172
|
+
- Library functions should return errors, not panic
|
|
173
|
+
- Recover only in deferred functions
|
|
174
|
+
- Convert internal panics to errors at package boundary
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### 10. Project Structure
|
|
178
|
+
|
|
179
|
+
```yaml
|
|
180
|
+
packages:
|
|
181
|
+
- One package per directory
|
|
182
|
+
- Package name matches directory name
|
|
183
|
+
- main package for executables
|
|
184
|
+
- Avoid circular imports
|
|
185
|
+
|
|
186
|
+
files:
|
|
187
|
+
- doc.go for package documentation
|
|
188
|
+
- _test.go suffix for test files
|
|
189
|
+
- Group related types and functions
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Application
|
|
193
|
+
|
|
194
|
+
When writing or reviewing Go code:
|
|
195
|
+
|
|
196
|
+
1. **Always** run `gofmt` or `goimports`
|
|
197
|
+
2. **Always** handle returned errors
|
|
198
|
+
3. **Prefer** composition over inheritance
|
|
199
|
+
4. **Prefer** small interfaces
|
|
200
|
+
5. **Prefer** channels for goroutine communication
|
|
201
|
+
6. **Avoid** global state
|
|
202
|
+
7. **Avoid** init() when possible
|
|
203
|
+
8. **Document** exported identifiers
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: help
|
|
3
|
+
description: Show help information for commands and system
|
|
4
|
+
argument-hint: "[command] [--agents] [--rules]"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Help Skill
|
|
8
|
+
|
|
9
|
+
Show help information for commands, agents, and system rules.
|
|
10
|
+
|
|
11
|
+
## Options
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
--agents, -a List all available agents
|
|
15
|
+
--commands, -c List all commands (same as 'lists')
|
|
16
|
+
--rules, -r List all rules
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Output Format
|
|
20
|
+
|
|
21
|
+
### Default Help
|
|
22
|
+
```
|
|
23
|
+
AI Agent System - Help
|
|
24
|
+
|
|
25
|
+
Usage: {command} [arguments] [options]
|
|
26
|
+
|
|
27
|
+
Quick Start:
|
|
28
|
+
lists Show all available commands
|
|
29
|
+
status Show system status
|
|
30
|
+
help <command> Get help for a specific command
|
|
31
|
+
|
|
32
|
+
Common Commands:
|
|
33
|
+
/update-docs Sync documentation with project
|
|
34
|
+
/update-external Update external agents
|
|
35
|
+
/audit-agents Check agent dependencies
|
|
36
|
+
/create-agent Create a new agent
|
|
37
|
+
|
|
38
|
+
Use "lists" to see all available commands.
|
|
39
|
+
Use "help <command>" for detailed help.
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Command Help
|
|
43
|
+
```
|
|
44
|
+
help /update-docs
|
|
45
|
+
|
|
46
|
+
Command: /update-docs
|
|
47
|
+
|
|
48
|
+
Description:
|
|
49
|
+
Sync documentation with project structure. Ensures all
|
|
50
|
+
documentation accurately reflects the current project state.
|
|
51
|
+
|
|
52
|
+
Usage:
|
|
53
|
+
/update-docs
|
|
54
|
+
/update-docs --check
|
|
55
|
+
/update-docs --target <path>
|
|
56
|
+
|
|
57
|
+
Options:
|
|
58
|
+
--check, -c Check only, don't modify
|
|
59
|
+
--verbose, -v Show detailed changes
|
|
60
|
+
--target, -t Specific target to update
|
|
61
|
+
|
|
62
|
+
Examples:
|
|
63
|
+
/update-docs # Update all documentation
|
|
64
|
+
/update-docs --check # Check for issues
|
|
65
|
+
/update-docs --target agents # Update agents only
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Agent List
|
|
69
|
+
```
|
|
70
|
+
help --agents
|
|
71
|
+
|
|
72
|
+
Available Agents:
|
|
73
|
+
|
|
74
|
+
Orchestrator:
|
|
75
|
+
secretary Manages manager agents
|
|
76
|
+
|
|
77
|
+
Manager:
|
|
78
|
+
mgr-creator Creates new agents
|
|
79
|
+
mgr-updater Updates external sources and docs
|
|
80
|
+
mgr-supplier Validates dependencies
|
|
81
|
+
|
|
82
|
+
SW Engineer:
|
|
83
|
+
lang-golang-expert Go development (Effective Go)
|
|
84
|
+
lang-python-expert Python development (PEP 8)
|
|
85
|
+
lang-rust-expert Rust development (API Guidelines)
|
|
86
|
+
lang-kotlin-expert Kotlin development (JetBrains)
|
|
87
|
+
lang-typescript-expert TypeScript development (Google)
|
|
88
|
+
fe-vercel-agent React/Next.js (Vercel)
|
|
89
|
+
|
|
90
|
+
Backend Engineer:
|
|
91
|
+
be-fastapi-expert FastAPI (Python async)
|
|
92
|
+
be-springboot-expert Spring Boot (Java)
|
|
93
|
+
be-go-backend-expert Go backend (Uber style)
|
|
94
|
+
|
|
95
|
+
Infra Engineer:
|
|
96
|
+
infra-docker-expert Docker containerization
|
|
97
|
+
infra-aws-expert AWS architecture
|
|
98
|
+
|
|
99
|
+
Total: 15 agents
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Rules List
|
|
103
|
+
```
|
|
104
|
+
help --rules
|
|
105
|
+
|
|
106
|
+
Global Rules:
|
|
107
|
+
|
|
108
|
+
MUST (Never violate):
|
|
109
|
+
R000 Language Policy Korean I/O, English files
|
|
110
|
+
R001 Safety Rules Prohibited actions
|
|
111
|
+
R002 Permission Rules Tool tiers, file access
|
|
112
|
+
R006 Agent Design Structure, separation
|
|
113
|
+
|
|
114
|
+
SHOULD (Strongly recommended):
|
|
115
|
+
R003 Interaction Rules Response format
|
|
116
|
+
R004 Error Handling Error levels, recovery
|
|
117
|
+
R007 Agent Identification Display agent in responses
|
|
118
|
+
R008 Tool Identification Display agent when using tools
|
|
119
|
+
|
|
120
|
+
MAY (Optional):
|
|
121
|
+
R005 Optimization Efficiency guidelines
|
|
122
|
+
R009 Parallel Execution Max 4 parallel instances
|
|
123
|
+
|
|
124
|
+
Total: 10 rules
|
|
125
|
+
```
|