@claude-code-mastery/starter-kit 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/.claude/.starter-kit/profiles/clean.md +113 -0
- package/.claude/.starter-kit/profiles/go.md +458 -0
- package/.claude/.starter-kit/profiles/node.md +429 -0
- package/.claude/.starter-kit/profiles/python.md +475 -0
- package/.claude/.starter-kit/shared/analytics-rybbit.md +55 -0
- package/.claude/.starter-kit/shared/claude-md-base.md +93 -0
- package/.claude/.starter-kit/shared/deployment-dokploy.md +158 -0
- package/.claude/.starter-kit/shared/feature-manifest.md +43 -0
- package/.claude/.starter-kit/shared/mcp-and-pooler.md +38 -0
- package/.claude/.starter-kit/shared/mongo-setup.md +20 -0
- package/.claude/.starter-kit/shared/profile-config.md +65 -0
- package/.claude/.starter-kit/shared/seo.md +113 -0
- package/.claude/.starter-kit/shared/sql-setup.md +37 -0
- package/.claude/commands/add-feature.md +349 -0
- package/.claude/commands/add-project-setup.md +156 -0
- package/.claude/commands/architecture.md +27 -0
- package/.claude/commands/commit.md +61 -0
- package/.claude/commands/convert-project-to-starter-kit.md +508 -0
- package/.claude/commands/create-api.md +385 -0
- package/.claude/commands/create-e2e.md +230 -0
- package/.claude/commands/diagram.md +301 -0
- package/.claude/commands/help.md +120 -0
- package/.claude/commands/install-global.md +145 -0
- package/.claude/commands/new-project.md +244 -0
- package/.claude/commands/optimize-docker.md +352 -0
- package/.claude/commands/progress.md +61 -0
- package/.claude/commands/projects-created.md +79 -0
- package/.claude/commands/quickstart.md +105 -0
- package/.claude/commands/refactor.md +267 -0
- package/.claude/commands/remove-project.md +95 -0
- package/.claude/commands/review.md +59 -0
- package/.claude/commands/security-check.md +77 -0
- package/.claude/commands/set-project-profile-default.md +79 -0
- package/.claude/commands/setup.md +337 -0
- package/.claude/commands/show-user-guide.md +58 -0
- package/.claude/commands/starter-kit.md +90 -0
- package/.claude/commands/test-plan.md +118 -0
- package/.claude/commands/update-project.md +413 -0
- package/.claude/commands/what-is-my-ai-doing.md +42 -0
- package/.claude/commands/worktree.md +124 -0
- package/.claude/hooks/block-dangerous-bash.py +55 -0
- package/.claude/hooks/check-branch.sh +116 -0
- package/.claude/hooks/check-e2e.sh +71 -0
- package/.claude/hooks/check-env-sync.sh +41 -0
- package/.claude/hooks/check-file-length.py +47 -0
- package/.claude/hooks/check-ports.sh +59 -0
- package/.claude/hooks/check-rulecatch.sh +33 -0
- package/.claude/hooks/check-rybbit.sh +63 -0
- package/.claude/hooks/lint-on-save.sh +59 -0
- package/.claude/hooks/verify-no-secrets.sh +80 -0
- package/.claude/settings.json +34 -0
- package/.claude/skills/api-conventions/SKILL.md +34 -0
- package/.claude/skills/code-review/SKILL.md +87 -0
- package/.claude/skills/code-review/references/mongodb-checks.md +25 -0
- package/.claude/skills/code-review/references/project-checks.md +38 -0
- package/.claude/skills/create-service/SKILL.md +222 -0
- package/.claude/skills/debugger/SKILL.md +39 -0
- package/.claude/skills/dependency-vetting/SKILL.md +46 -0
- package/.claude/skills/design-review/SKILL.md +50 -0
- package/.claude/skills/mcp-builder/SKILL.md +57 -0
- package/.claude/skills/mongodb-rules/SKILL.md +62 -0
- package/.claude/skills/terminal-tui/SKILL.md +106 -0
- package/.claude/skills/test-writer/SKILL.md +78 -0
- package/LICENSE +21 -0
- package/README.md +2152 -0
- package/bin/cli.js +205 -0
- package/claude-mastery-project.conf +220 -0
- package/global-claude-md/CLAUDE.md +212 -0
- package/global-claude-md/settings.json +3 -0
- package/package.json +81 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
<!-- Part of /new-project scaffolding. Read via .claude/commands/new-project.md when the selection requires it; not a standalone command. -->
|
|
2
|
+
|
|
3
|
+
## Clean Mode — `clean`
|
|
4
|
+
|
|
5
|
+
**If `clean` is detected in arguments, skip ALL of Steps 1-2 below and follow this section instead.**
|
|
6
|
+
|
|
7
|
+
Clean mode gives the user every piece of Claude Code infrastructure without imposing ANY opinions about how they should code, what language to use, what framework to pick, or how to structure their source code.
|
|
8
|
+
|
|
9
|
+
### What `clean` creates
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
project/
|
|
13
|
+
├── CLAUDE.md # Security rules ONLY (see below)
|
|
14
|
+
├── CLAUDE.local.md # Personal overrides template
|
|
15
|
+
├── .claude/
|
|
16
|
+
│ ├── settings.json # Hooks configuration
|
|
17
|
+
│ ├── commands/ # Only scope: project commands (16 of 27)
|
|
18
|
+
│ │ ├── architecture.md
|
|
19
|
+
│ │ ├── commit.md
|
|
20
|
+
│ │ ├── create-api.md
|
|
21
|
+
│ │ ├── create-e2e.md
|
|
22
|
+
│ │ ├── diagram.md
|
|
23
|
+
│ │ ├── help.md
|
|
24
|
+
│ │ ├── optimize-docker.md
|
|
25
|
+
│ │ ├── progress.md
|
|
26
|
+
│ │ ├── refactor.md
|
|
27
|
+
│ │ ├── review.md
|
|
28
|
+
│ │ ├── security-check.md
|
|
29
|
+
│ │ ├── setup.md
|
|
30
|
+
│ │ ├── show-user-guide.md
|
|
31
|
+
│ │ ├── test-plan.md
|
|
32
|
+
│ │ ├── what-is-my-ai-doing.md
|
|
33
|
+
│ │ └── worktree.md
|
|
34
|
+
│ ├── skills/
|
|
35
|
+
│ │ ├── code-review/SKILL.md
|
|
36
|
+
│ │ └── create-service/SKILL.md
|
|
37
|
+
│ │ ├── code-reviewer.md
|
|
38
|
+
│ │ └── test-writer.md
|
|
39
|
+
│ └── hooks/
|
|
40
|
+
│ ├── lint-on-save.sh
|
|
41
|
+
│ └── verify-no-secrets.sh
|
|
42
|
+
├── project-docs/
|
|
43
|
+
│ ├── ARCHITECTURE.md
|
|
44
|
+
│ ├── INFRASTRUCTURE.md
|
|
45
|
+
│ └── DECISIONS.md
|
|
46
|
+
├── tests/
|
|
47
|
+
│ ├── CHECKLIST.md
|
|
48
|
+
│ └── ISSUES_FOUND.md
|
|
49
|
+
├── .env # Empty (NEVER commit)
|
|
50
|
+
├── .env.example # Template with NODE_ENV and PORT
|
|
51
|
+
├── .gitignore # Standard ignores
|
|
52
|
+
├── .dockerignore # Standard ignores
|
|
53
|
+
└── README.md # Minimal project readme
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### What `clean` does NOT create
|
|
57
|
+
|
|
58
|
+
- No `src/` directory — user decides their own structure
|
|
59
|
+
- No `package.json` — user picks their own language, runtime, and package manager
|
|
60
|
+
- No `tsconfig.json` — user may not even use TypeScript
|
|
61
|
+
- No `vitest.config.ts` or `playwright.config.ts` — user picks their own test tools
|
|
62
|
+
- No database setup or `scripts/db-query.ts` — user picks their own database
|
|
63
|
+
- No content builder — user decides if they need one
|
|
64
|
+
- No SEO templates — user decides their own approach
|
|
65
|
+
- No port assignments — user decides their own ports
|
|
66
|
+
- No framework-specific configs — user picks their own framework
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
> The CLAUDE.md for `clean` mode is exactly `../shared/claude-md-base.md` (universal, non-opinionated rules), with no profile-specific additions. Read it and write it as the project CLAUDE.md.
|
|
70
|
+
|
|
71
|
+
### Clean mode steps
|
|
72
|
+
|
|
73
|
+
1. Resolve project path (same as Step 0 / 0.1 above)
|
|
74
|
+
2. **Run the batch scaffold script** — this replaces all individual file creation with a single command:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
bash "$(pwd)/scripts/scaffold-clean.sh" "$PROJECT_PATH" "$PROJECT_NAME" "$(pwd)"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The script handles ALL of the following in one execution (~100ms) with a progress indicator:
|
|
81
|
+
- Creates all directories (.claude/, project-docs/, tests/)
|
|
82
|
+
- Copies project-scoped commands, all skills, and all hooks
|
|
83
|
+
- Writes settings.json (clean mode — 3 hooks only)
|
|
84
|
+
- Creates CLAUDE.md (security rules only), CLAUDE.local.md
|
|
85
|
+
- Creates project-docs templates (ARCHITECTURE, INFRASTRUCTURE, DECISIONS)
|
|
86
|
+
- Creates tests templates (CHECKLIST, ISSUES_FOUND)
|
|
87
|
+
- Creates .env, .env.example, .gitignore, .dockerignore, README.md
|
|
88
|
+
- Initializes git with initial commit
|
|
89
|
+
- Registers the project in ~/.claude/starter-kit-projects.json
|
|
90
|
+
|
|
91
|
+
**Do NOT create files individually — the script handles everything.**
|
|
92
|
+
|
|
93
|
+
3. After the script completes, display the verification checklist (the script output includes a summary)
|
|
94
|
+
|
|
95
|
+
### Clean verification checklist
|
|
96
|
+
|
|
97
|
+
- [ ] `.claude/` directory with `scope: project` commands only (16), skills, hooks
|
|
98
|
+
- [ ] `.claude/settings.json` with hooks wired up
|
|
99
|
+
- [ ] `CLAUDE.md` has ONLY security rules (no TypeScript, no ports, no quality gates)
|
|
100
|
+
- [ ] `project-docs/` has all three templates
|
|
101
|
+
- [ ] `tests/` has CHECKLIST.md and ISSUES_FOUND.md
|
|
102
|
+
- [ ] `.env` exists (empty)
|
|
103
|
+
- [ ] `.env.example` exists
|
|
104
|
+
- [ ] `.gitignore` includes .env, node_modules/, dist/, CLAUDE.local.md
|
|
105
|
+
- [ ] `.dockerignore` exists
|
|
106
|
+
- [ ] NO `package.json`, `tsconfig.json`, or framework configs created
|
|
107
|
+
- [ ] NO `src/` directory created
|
|
108
|
+
- [ ] Git initialized with initial commit
|
|
109
|
+
|
|
110
|
+
**After creating a `clean` project, the user can add their own language, framework, and structure — Claude will follow the security rules and use the slash commands without imposing any coding patterns.**
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
<!-- Part of /new-project scaffolding. Read via .claude/commands/new-project.md when the selection requires it; not a standalone command. -->
|
|
2
|
+
|
|
3
|
+
> This profile builds its CLAUDE.md from `../shared/claude-md-base.md` (the universal rules) plus the profile-specific rules below. Read the base first.
|
|
4
|
+
|
|
5
|
+
## Go Mode — `go` / `golang`
|
|
6
|
+
|
|
7
|
+
**If `go`, `golang`, or a Go framework (`gin`, `chi`, `echo`, `fiber`, `stdlib`) is detected in arguments, OR the resolved profile has `language = go`, skip ALL of Steps 1-2 below and follow this section instead.**
|
|
8
|
+
|
|
9
|
+
Go Mode scaffolds a Go project with standard layout conventions (`cmd/`, `internal/`), a Makefile-based build system, golangci-lint, and multi-stage Docker with `scratch` base image.
|
|
10
|
+
|
|
11
|
+
### Go Questions (skip any answered by arguments or profile)
|
|
12
|
+
|
|
13
|
+
#### Question G1: Project Type
|
|
14
|
+
"What type of Go project are you building?"
|
|
15
|
+
- **API** — REST API server (Recommended)
|
|
16
|
+
- **Web App** — HTTP server with templates
|
|
17
|
+
- **CLI** — Command-line tool
|
|
18
|
+
- **Full-Stack** — Go API backend + separate frontend
|
|
19
|
+
|
|
20
|
+
#### Question G2: Framework (based on project type)
|
|
21
|
+
|
|
22
|
+
**If API or Web App or Full-Stack:**
|
|
23
|
+
"Which Go HTTP framework?"
|
|
24
|
+
- **Gin** — Most popular Go web framework, fast, great middleware (Recommended)
|
|
25
|
+
- **Chi** — Lightweight, idiomatic, stdlib-compatible router
|
|
26
|
+
- **Echo** — High performance, extensible, automatic TLS
|
|
27
|
+
- **Fiber** — Express-inspired, built on fasthttp
|
|
28
|
+
- **stdlib** — Standard library `net/http` only, zero dependencies
|
|
29
|
+
|
|
30
|
+
**If CLI:**
|
|
31
|
+
- Use **Cobra** + **Viper** (no framework question needed)
|
|
32
|
+
|
|
33
|
+
#### Question G3: Database
|
|
34
|
+
"Which database?"
|
|
35
|
+
- **MongoDB** — Document database (Recommended for APIs)
|
|
36
|
+
- **PostgreSQL** — Relational database (Recommended for SQL)
|
|
37
|
+
- **MySQL** — Relational, widely deployed
|
|
38
|
+
- **MSSQL** — Microsoft SQL Server
|
|
39
|
+
- **SQLite** — Embedded, file-based, zero config
|
|
40
|
+
- **None** — No database
|
|
41
|
+
|
|
42
|
+
#### Question G3.1: MongoDB Connection String (only if MongoDB selected in G3)
|
|
43
|
+
"Do you want to configure your MongoDB connection now?"
|
|
44
|
+
- **Yes, I have a connection string** — User pastes their full `mongodb+srv://...` URI. Write it to `.env` as `STRICTDB_URI=<their-value>`.
|
|
45
|
+
- **No, I'll set it up later** — Skip. Leave `STRICTDB_URI` placeholder in `.env.example` only.
|
|
46
|
+
|
|
47
|
+
If the user provides a connection string:
|
|
48
|
+
1. Write `STRICTDB_URI=<value>` to the project's `.env`
|
|
49
|
+
2. If no database name in URI, ask: "What should the database be called?" and append it to the URI
|
|
50
|
+
|
|
51
|
+
#### Question G4: Hosting / Deployment
|
|
52
|
+
"Where will this be deployed?" (same as Node.js options)
|
|
53
|
+
- **Dokploy on Hostinger VPS** — Self-hosted Docker containers (Recommended)
|
|
54
|
+
- **Vercel** — Not ideal for Go, but possible via serverless
|
|
55
|
+
- **Static hosting** — Not applicable for Go APIs
|
|
56
|
+
- **None / Decide later** — Skip deployment scaffolding
|
|
57
|
+
|
|
58
|
+
#### Question G5: Extras (multi-select)
|
|
59
|
+
"What extras do you want to include?"
|
|
60
|
+
- **Docker** — Multi-stage build with scratch base (5-15MB images)
|
|
61
|
+
- **GitHub Actions CI** — Automated testing pipeline (go test, go vet, golangci-lint)
|
|
62
|
+
- **golangci-lint** — Comprehensive Go linter (recommended, on by default)
|
|
63
|
+
|
|
64
|
+
### Go Project Structure
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
project/
|
|
68
|
+
├── cmd/
|
|
69
|
+
│ └── server/
|
|
70
|
+
│ └── main.go # Entry point
|
|
71
|
+
├── internal/
|
|
72
|
+
│ ├── handlers/
|
|
73
|
+
│ │ └── health.go # Health check handler
|
|
74
|
+
│ ├── middleware/
|
|
75
|
+
│ │ └── logging.go # Request logging middleware
|
|
76
|
+
│ ├── models/
|
|
77
|
+
│ │ └── models.go # Data models
|
|
78
|
+
│ └── database/
|
|
79
|
+
│ └── mongo.go # Database layer (if MongoDB)
|
|
80
|
+
├── tests/
|
|
81
|
+
│ └── handlers_test.go # Handler tests
|
|
82
|
+
├── scripts/
|
|
83
|
+
│ └── deploy.sh # Deployment script (if Dokploy)
|
|
84
|
+
├── project-docs/
|
|
85
|
+
│ ├── ARCHITECTURE.md
|
|
86
|
+
│ ├── INFRASTRUCTURE.md
|
|
87
|
+
│ └── DECISIONS.md
|
|
88
|
+
├── .claude/
|
|
89
|
+
│ ├── commands/
|
|
90
|
+
│ ├── skills/
|
|
91
|
+
│ ├── hooks/
|
|
92
|
+
│ └── settings.json
|
|
93
|
+
├── go.mod
|
|
94
|
+
├── go.sum
|
|
95
|
+
├── Makefile
|
|
96
|
+
├── Dockerfile # Multi-stage: golang:1.23-alpine → scratch
|
|
97
|
+
├── .golangci.yml
|
|
98
|
+
├── .env
|
|
99
|
+
├── .env.example
|
|
100
|
+
├── .gitignore
|
|
101
|
+
├── .dockerignore
|
|
102
|
+
├── CLAUDE.md
|
|
103
|
+
├── CLAUDE.local.md
|
|
104
|
+
└── README.md
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Go Template: `cmd/server/main.go` (Gin)
|
|
108
|
+
|
|
109
|
+
```go
|
|
110
|
+
package main
|
|
111
|
+
|
|
112
|
+
import (
|
|
113
|
+
"context"
|
|
114
|
+
"log"
|
|
115
|
+
"net/http"
|
|
116
|
+
"os"
|
|
117
|
+
"os/signal"
|
|
118
|
+
"syscall"
|
|
119
|
+
"time"
|
|
120
|
+
|
|
121
|
+
"github.com/gin-gonic/gin"
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
func main() {
|
|
125
|
+
port := os.Getenv("PORT")
|
|
126
|
+
if port == "" {
|
|
127
|
+
port = "3001"
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if os.Getenv("GIN_MODE") == "" {
|
|
131
|
+
gin.SetMode(gin.ReleaseMode)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
r := gin.New()
|
|
135
|
+
r.Use(gin.Logger(), gin.Recovery())
|
|
136
|
+
|
|
137
|
+
// Health check
|
|
138
|
+
r.GET("/health", func(c *gin.Context) {
|
|
139
|
+
c.JSON(http.StatusOK, gin.H{"status": "ok"})
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
// API v1 routes
|
|
143
|
+
v1 := r.Group("/api/v1")
|
|
144
|
+
{
|
|
145
|
+
v1.GET("/ping", func(c *gin.Context) {
|
|
146
|
+
c.JSON(http.StatusOK, gin.H{"message": "pong"})
|
|
147
|
+
})
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
srv := &http.Server{
|
|
151
|
+
Addr: ":" + port,
|
|
152
|
+
Handler: r,
|
|
153
|
+
ReadTimeout: 10 * time.Second,
|
|
154
|
+
WriteTimeout: 10 * time.Second,
|
|
155
|
+
IdleTimeout: 60 * time.Second,
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Graceful shutdown
|
|
159
|
+
go func() {
|
|
160
|
+
log.Printf("Server starting on :%s", port)
|
|
161
|
+
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
|
162
|
+
log.Fatalf("Server failed: %v", err)
|
|
163
|
+
}
|
|
164
|
+
}()
|
|
165
|
+
|
|
166
|
+
quit := make(chan os.Signal, 1)
|
|
167
|
+
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
|
168
|
+
<-quit
|
|
169
|
+
log.Println("Shutting down server...")
|
|
170
|
+
|
|
171
|
+
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
172
|
+
defer cancel()
|
|
173
|
+
if err := srv.Shutdown(ctx); err != nil {
|
|
174
|
+
log.Fatalf("Server forced to shutdown: %v", err)
|
|
175
|
+
}
|
|
176
|
+
log.Println("Server exited")
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**For other frameworks, adapt accordingly:**
|
|
181
|
+
- **Chi:** Use `chi.NewRouter()` with `chi.Use(middleware.Logger)` and `r.Route("/api/v1", ...)`
|
|
182
|
+
- **Echo:** Use `echo.New()` with `e.Use(middleware.Logger())` and `e.Group("/api/v1")`
|
|
183
|
+
- **Fiber:** Use `fiber.New()` with `app.Use(logger.New())` and `app.Group("/api/v1")`
|
|
184
|
+
- **stdlib:** Use `http.NewServeMux()` with `mux.Handle("/api/v1/", ...)` and manual middleware
|
|
185
|
+
|
|
186
|
+
### Go Template: `Makefile`
|
|
187
|
+
|
|
188
|
+
```makefile
|
|
189
|
+
BINARY_NAME=server
|
|
190
|
+
BUILD_DIR=bin
|
|
191
|
+
GO=go
|
|
192
|
+
|
|
193
|
+
.PHONY: all build run dev test test-cover lint vet fmt check clean
|
|
194
|
+
|
|
195
|
+
all: check build
|
|
196
|
+
|
|
197
|
+
build:
|
|
198
|
+
CGO_ENABLED=0 $(GO) build -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/server
|
|
199
|
+
|
|
200
|
+
run: build
|
|
201
|
+
./$(BUILD_DIR)/$(BINARY_NAME)
|
|
202
|
+
|
|
203
|
+
dev:
|
|
204
|
+
@command -v air > /dev/null 2>&1 || $(GO) install github.com/air-verse/air@latest
|
|
205
|
+
air
|
|
206
|
+
|
|
207
|
+
test:
|
|
208
|
+
$(GO) test ./... -v
|
|
209
|
+
|
|
210
|
+
test-cover:
|
|
211
|
+
$(GO) test ./... -coverprofile=coverage.out
|
|
212
|
+
$(GO) tool cover -html=coverage.out -o coverage.html
|
|
213
|
+
|
|
214
|
+
lint:
|
|
215
|
+
@command -v golangci-lint > /dev/null 2>&1 || $(GO) install github.com/golangci-lint/golangci-lint/cmd/golangci-lint@latest
|
|
216
|
+
golangci-lint run
|
|
217
|
+
|
|
218
|
+
vet:
|
|
219
|
+
$(GO) vet ./...
|
|
220
|
+
|
|
221
|
+
fmt:
|
|
222
|
+
$(GO) fmt ./...
|
|
223
|
+
goimports -w .
|
|
224
|
+
|
|
225
|
+
check: vet lint
|
|
226
|
+
|
|
227
|
+
clean:
|
|
228
|
+
rm -rf $(BUILD_DIR) coverage.out coverage.html
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Go Template: `Dockerfile` (multi-stage with scratch)
|
|
232
|
+
|
|
233
|
+
```dockerfile
|
|
234
|
+
# Stage 1: Builder
|
|
235
|
+
FROM golang:1.23-alpine AS builder
|
|
236
|
+
WORKDIR /app
|
|
237
|
+
|
|
238
|
+
# Install git for go mod download (some deps need it)
|
|
239
|
+
RUN apk add --no-cache git
|
|
240
|
+
|
|
241
|
+
# Cache dependencies
|
|
242
|
+
COPY go.mod go.sum ./
|
|
243
|
+
RUN go mod download
|
|
244
|
+
|
|
245
|
+
# Build static binary
|
|
246
|
+
COPY . .
|
|
247
|
+
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /server ./cmd/server
|
|
248
|
+
|
|
249
|
+
# Stage 2: Scratch (minimal image)
|
|
250
|
+
FROM scratch
|
|
251
|
+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
|
252
|
+
COPY --from=builder /server /server
|
|
253
|
+
|
|
254
|
+
EXPOSE 3001
|
|
255
|
+
ENTRYPOINT ["/server"]
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Go Template: `.golangci.yml`
|
|
259
|
+
|
|
260
|
+
```yaml
|
|
261
|
+
run:
|
|
262
|
+
timeout: 3m
|
|
263
|
+
|
|
264
|
+
linters:
|
|
265
|
+
enable:
|
|
266
|
+
- errcheck
|
|
267
|
+
- govet
|
|
268
|
+
- staticcheck
|
|
269
|
+
- unused
|
|
270
|
+
- gosimple
|
|
271
|
+
- ineffassign
|
|
272
|
+
- typecheck
|
|
273
|
+
- gocritic
|
|
274
|
+
- gofmt
|
|
275
|
+
- goimports
|
|
276
|
+
- misspell
|
|
277
|
+
- nilerr
|
|
278
|
+
- exhaustive
|
|
279
|
+
|
|
280
|
+
linters-settings:
|
|
281
|
+
gocritic:
|
|
282
|
+
enabled-tags:
|
|
283
|
+
- diagnostic
|
|
284
|
+
- style
|
|
285
|
+
- performance
|
|
286
|
+
errcheck:
|
|
287
|
+
check-blank: true
|
|
288
|
+
|
|
289
|
+
issues:
|
|
290
|
+
exclude-use-default: false
|
|
291
|
+
max-issues-per-linter: 50
|
|
292
|
+
max-same-issues: 10
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Go Template: `.gitignore`
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
# Binaries
|
|
299
|
+
bin/
|
|
300
|
+
*.exe
|
|
301
|
+
*.exe~
|
|
302
|
+
*.dll
|
|
303
|
+
*.so
|
|
304
|
+
*.dylib
|
|
305
|
+
|
|
306
|
+
# Test
|
|
307
|
+
coverage.out
|
|
308
|
+
coverage.html
|
|
309
|
+
|
|
310
|
+
# Environment
|
|
311
|
+
.env
|
|
312
|
+
.env.*
|
|
313
|
+
.env.local
|
|
314
|
+
|
|
315
|
+
# IDE
|
|
316
|
+
.idea/
|
|
317
|
+
.vscode/
|
|
318
|
+
*.swp
|
|
319
|
+
*.swo
|
|
320
|
+
|
|
321
|
+
# OS
|
|
322
|
+
.DS_Store
|
|
323
|
+
Thumbs.db
|
|
324
|
+
|
|
325
|
+
# Vendor (if not committed)
|
|
326
|
+
# vendor/
|
|
327
|
+
|
|
328
|
+
# Build artifacts
|
|
329
|
+
dist/
|
|
330
|
+
tmp/
|
|
331
|
+
|
|
332
|
+
# Claude local overrides
|
|
333
|
+
CLAUDE.local.md
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### Go-Specific CLAUDE.md Rules
|
|
337
|
+
|
|
338
|
+
When creating a Go project, the CLAUDE.md MUST include these Go-specific rules:
|
|
339
|
+
|
|
340
|
+
```markdown
|
|
341
|
+
### Go Rules
|
|
342
|
+
|
|
343
|
+
#### Error Handling — NEVER Ignore Errors
|
|
344
|
+
- ALWAYS check returned errors — never use `_` to discard an error
|
|
345
|
+
- Use `fmt.Errorf("context: %w", err)` to wrap errors with context
|
|
346
|
+
- Return errors to callers — don't log and continue silently
|
|
347
|
+
- Use sentinel errors or custom error types for expected error conditions
|
|
348
|
+
|
|
349
|
+
#### Context Propagation — ALWAYS Pass context.Context
|
|
350
|
+
- Every function that does I/O (HTTP, DB, file) MUST accept `context.Context` as first param
|
|
351
|
+
- NEVER use `context.Background()` in handlers — use the request context `c.Request.Context()`
|
|
352
|
+
- Set timeouts on all external calls: `context.WithTimeout(ctx, 5*time.Second)`
|
|
353
|
+
|
|
354
|
+
#### Testing — Table-Driven Tests
|
|
355
|
+
- Use table-driven tests for functions with multiple input/output scenarios
|
|
356
|
+
- Test files MUST be in the same package (white-box) or `_test` package (black-box)
|
|
357
|
+
- Use `testify/assert` or stdlib `testing` — no other test frameworks
|
|
358
|
+
- Run tests with `make test` or `go test ./... -v`
|
|
359
|
+
|
|
360
|
+
#### Interfaces — Accept Interfaces, Return Structs
|
|
361
|
+
- Define interfaces at the consumer, not the implementer
|
|
362
|
+
- Keep interfaces small (1-3 methods)
|
|
363
|
+
- Use interfaces for dependency injection (database, HTTP clients, etc.)
|
|
364
|
+
|
|
365
|
+
#### No Global Mutable State
|
|
366
|
+
- NEVER use package-level `var` for mutable state
|
|
367
|
+
- Pass dependencies via struct fields or function parameters
|
|
368
|
+
- Configuration should be loaded once at startup and passed down
|
|
369
|
+
|
|
370
|
+
#### API Versioning
|
|
371
|
+
- ALL endpoints MUST use `/api/v1/` prefix — same rule as Node.js projects
|
|
372
|
+
|
|
373
|
+
#### Quality Gates
|
|
374
|
+
- No file > 300 lines (split into separate files in the same package)
|
|
375
|
+
- No function > 50 lines (extract helper functions)
|
|
376
|
+
- `go vet` and `golangci-lint` must pass before committing
|
|
377
|
+
- `go build ./...` must succeed with no errors
|
|
378
|
+
|
|
379
|
+
#### Graceful Shutdown — MANDATORY
|
|
380
|
+
- Every server MUST handle SIGINT and SIGTERM
|
|
381
|
+
- Close database connections before exiting
|
|
382
|
+
- Use `context.WithTimeout` for shutdown deadline
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### Go Scaffolding Steps
|
|
386
|
+
|
|
387
|
+
1. Create project directory
|
|
388
|
+
2. Run `go mod init github.com/<username>/<project-name>` (get username from git config or ask)
|
|
389
|
+
3. Create Go directory structure: `cmd/server/`, `internal/handlers/`, `internal/middleware/`, `internal/models/`, `internal/database/` (if DB selected), `tests/`, `scripts/`
|
|
390
|
+
4. Write framework-specific `main.go` (using template above, adapted for chosen framework)
|
|
391
|
+
5. Write `internal/handlers/health.go` — health check handler
|
|
392
|
+
6. Write database layer `internal/database/` if database was selected
|
|
393
|
+
7. Create `Makefile` (using template above)
|
|
394
|
+
8. Create `Dockerfile` (multi-stage with scratch, using template above)
|
|
395
|
+
9. Create `.golangci.yml` (using template above)
|
|
396
|
+
10. Create Go-specific `CLAUDE.md` (with Go rules above + universal security rules)
|
|
397
|
+
11. Copy `.claude/` contents from starter kit — only commands with `scope: project` in frontmatter (skills, hooks, settings.json copied in full)
|
|
398
|
+
12. Create `project-docs/` templates (ARCHITECTURE.md, INFRASTRUCTURE.md, DECISIONS.md)
|
|
399
|
+
13. Create `.env`, `.env.example`, `.gitignore` (Go-specific), `.dockerignore`
|
|
400
|
+
14. Create `CLAUDE.local.md` template
|
|
401
|
+
15. Create `README.md` with Go-specific instructions
|
|
402
|
+
16. Create `scripts/deploy.sh` if Dokploy hosting was selected
|
|
403
|
+
17. Run `go mod tidy` to resolve dependencies
|
|
404
|
+
18. Initialize git, create initial commit: "Initial Go project scaffold"
|
|
405
|
+
19. Display verification checklist
|
|
406
|
+
|
|
407
|
+
### Go Verification Checklist
|
|
408
|
+
|
|
409
|
+
After creation, verify and report:
|
|
410
|
+
|
|
411
|
+
**Core files:**
|
|
412
|
+
- [ ] `go.mod` exists with correct module path
|
|
413
|
+
- [ ] `go.sum` exists (after `go mod tidy`)
|
|
414
|
+
- [ ] `Makefile` exists with build, test, lint targets
|
|
415
|
+
- [ ] `.env` exists
|
|
416
|
+
- [ ] `.env.example` exists with PORT placeholder
|
|
417
|
+
- [ ] `.gitignore` includes Go-specific entries (bin/, *.exe, .env)
|
|
418
|
+
- [ ] `.dockerignore` exists
|
|
419
|
+
- [ ] `CLAUDE.md` has Go-specific rules (error handling, context, testing)
|
|
420
|
+
- [ ] `CLAUDE.local.md` exists
|
|
421
|
+
|
|
422
|
+
**Structure:**
|
|
423
|
+
- [ ] `cmd/server/main.go` exists with entry point
|
|
424
|
+
- [ ] `internal/handlers/health.go` exists
|
|
425
|
+
- [ ] `internal/middleware/` directory exists
|
|
426
|
+
- [ ] `internal/models/` directory exists
|
|
427
|
+
- [ ] `tests/` directory exists with at least one test
|
|
428
|
+
- [ ] `project-docs/` has ARCHITECTURE.md, INFRASTRUCTURE.md, DECISIONS.md
|
|
429
|
+
- [ ] `.claude/` has `scope: project` commands only, skills, hooks, settings.json
|
|
430
|
+
|
|
431
|
+
**Testing:**
|
|
432
|
+
- [ ] `go build ./...` succeeds
|
|
433
|
+
- [ ] `go vet ./...` passes
|
|
434
|
+
- [ ] `go test ./...` runs (even if no tests yet)
|
|
435
|
+
|
|
436
|
+
**Database (if selected):**
|
|
437
|
+
- [ ] `internal/database/` exists with connection layer
|
|
438
|
+
- [ ] Database URL in `.env.example`
|
|
439
|
+
|
|
440
|
+
**Docker (if selected):**
|
|
441
|
+
- [ ] `Dockerfile` exists with multi-stage build (golang:1.23-alpine → scratch)
|
|
442
|
+
- [ ] Final image is minimal (no compiler, no source code)
|
|
443
|
+
|
|
444
|
+
**Infrastructure:**
|
|
445
|
+
- [ ] `scripts/deploy.sh` exists (if Dokploy selected)
|
|
446
|
+
- [ ] `.golangci.yml` exists
|
|
447
|
+
- [ ] Git initialized with initial commit
|
|
448
|
+
|
|
449
|
+
**NOT present (Go projects should NOT have):**
|
|
450
|
+
- [ ] No `package.json` — this is a Go project
|
|
451
|
+
- [ ] No `tsconfig.json`
|
|
452
|
+
- [ ] No `node_modules/`
|
|
453
|
+
- [ ] No `vitest.config.ts` or `playwright.config.ts`
|
|
454
|
+
|
|
455
|
+
Report any missing items.
|
|
456
|
+
|
|
457
|
+
---
|
|
458
|
+
|