docs: add from-scratch bootstrap steps for agent

- Prerequisites check
- Clone + checkout instructions
- Build and smoke test commands
- Development loop (edit → build → vet → test)
- Git user config with sign-off

Signed-off-by: Boos4721 <boos4721@icloud.com>
This commit is contained in:
boos
2026-05-16 01:17:30 +08:00
parent 75acbab6c1
commit 5f172ea568
+75 -1
View File
@@ -2,11 +2,85 @@
You are a senior Go developer tasked with rewriting the BoosAPI backend from Node.js/Fastify/TypeScript to Go. The frontend (React SPA) and database schema remain unchanged. You are a senior Go developer tasked with rewriting the BoosAPI backend from Node.js/Fastify/TypeScript to Go. The frontend (React SPA) and database schema remain unchanged.
## Getting Started (from scratch)
### Prerequisites
The agent must have these tools available:
- `git` — clone and push code
- `go` (1.26+) — build and test
- `gofmt` — code formatting (comes with Go)
- `curl` — API testing
- `docker` (optional) — container build
### Step-by-step bootstrap
```bash
# 1. Clone the repository
git clone https://git.boos.lat/boos/BoosAPI.git boosapi-go
cd boosapi-go
# 2. Checkout the rewrite branch
git checkout refactor/go-backend
# 3. Verify Go version
go version # must be 1.26+, install if missing
# 4. Build Phase 1 scaffold
CGO_ENABLED=0 go build ./cmd/boosapi/
# 5. Quick smoke test
AUTH_TOKEN=admin PROXY_TOKEN=proxy ./boosapi &
sleep 2
curl -s http://localhost:4000/healthz
# Expected: {"status":"ok","database":"ok",...}
kill %1
# 6. Run existing tests
go test ./... -count=1
go vet ./...
# 7. Verify Phase 1 is complete
ls cmd/boosapi/main.go
ls internal/config/config.go
ls internal/db/db.go
ls internal/server/middleware/middleware.go
ls internal/server/handler/health.go
ls internal/db/migrate/000001_initial.up.sql
ls docker/Dockerfile
# All should exist
```
### Development loop
```bash
# Edit code, then:
CGO_ENABLED=0 go build ./cmd/boosapi/ # compile check
go vet ./... # static analysis
go test ./... -count=1 -v # run tests (add -run TestName for specific)
AUTH_TOKEN=admin PROXY_TOKEN=proxy ./boosapi & # manual test
curl http://localhost:4000/healthz
kill %1
# Before commit:
gofmt -s -w . # format all Go files
go vet ./... # final vet check
go test ./... # final test run
```
### Git configuration
```bash
git config user.name "Boos4721"
git config user.email "boos4721@icloud.com"
# Always sign off commits: git commit -s
```
## Repository ## Repository
- **Branch:** `refactor/go-backend` - **Branch:** `refactor/go-backend`
- **Remote:** `gitea` (`https://git.boos.lat/boos/BoosAPI.git`) - **Remote:** `gitea` (`https://git.boos.lat/boos/BoosAPI.git`)
- **Go version:** 1.26 - **Go version:** 1.26+
- **Module:** `github.com/cita-777/boosapi` - **Module:** `github.com/cita-777/boosapi`
## Golden Rules ## Golden Rules