|
| 1 | +# Patternizer - Agent Guidelines |
| 2 | + |
| 3 | +Patternizer is a Go CLI tool that bootstraps Git repositories containing Helm charts into ready-to-use Validated Patterns. Module path: `github.com/validatedpatterns/patternizer`. |
| 4 | + |
| 5 | +## Build, Lint, and Test |
| 6 | + |
| 7 | +Run `make dev-setup` once to install tooling (golangci-lint, ginkgo). |
| 8 | + |
| 9 | +Key make targets: |
| 10 | + |
| 11 | +- `make ci` - Full CI pipeline: lint, build, test. Run this before considering any change complete. |
| 12 | +- `make build` - Build the binary. |
| 13 | +- `make test` - Run all tests via Ginkgo. |
| 14 | +- `make lint` - Run all linters (gofmt, go vet, golangci-lint). |
| 15 | +- `make fmt` - Auto-format Go code. |
| 16 | +- `make check` - Quick check: format, vet, build, unit tests. |
| 17 | + |
| 18 | +All Go source lives under `src/`. The Makefile handles `cd src` automatically. |
| 19 | + |
| 20 | +## Code Style |
| 21 | + |
| 22 | +- No unnecessary inline comments. Code should be self-documenting through clear naming and structure. |
| 23 | +- No emojis, ASCII art, or non-standard characters anywhere in the codebase. |
| 24 | +- Exported functions must have godoc comments (enforced by the revive linter). |
| 25 | +- Run `make fmt` before committing. Formatting is checked by `make lint`. |
| 26 | +- Follow the existing project layout: |
| 27 | + - `src/cmd/` - Cobra CLI command definitions. |
| 28 | + - `src/internal/` - Private packages (not importable externally). |
| 29 | + - `src/internal/types/` - Shared data structures. |
| 30 | + - `src/internal/embedded/` - Embedded resources via `go:embed`. |
| 31 | + |
| 32 | +## Go Best Practices |
| 33 | + |
| 34 | +- Wrap errors with context: `fmt.Errorf("description: %w", err)`. |
| 35 | +- Break large functions into smaller, well-named helper functions. Each function should do one thing. |
| 36 | +- Keep `main.go` minimal; delegate to `cmd.Execute()`. |
| 37 | +- Use `internal/` to keep implementation details private. |
| 38 | +- Use `go:embed` for bundled resources (see `internal/embedded/`). |
| 39 | +- CLI commands use Cobra. Add new commands by registering them on `rootCmd` in `cmd/root.go`. |
| 40 | + |
| 41 | +## Testing |
| 42 | + |
| 43 | +- Tests must be added or updated when writing new code. |
| 44 | +- The project uses Ginkgo v2 and Gomega (BDD style: `Describe`/`Context`/`It`). |
| 45 | +- Test files live alongside source files as `*_test.go`. |
| 46 | +- Each package with tests needs a `*_suite_test.go` file for Ginkgo bootstrap. |
| 47 | +- Use `GinkgoT().TempDir()` for temporary directories in tests. |
| 48 | +- Run `make test` to execute all tests (`ginkgo -v ./...`). |
| 49 | + |
| 50 | +## Versioning |
| 51 | + |
| 52 | +The project version is tracked in the shield badge on line 1 of `README.md` (e.g. ``). Bump it once per session or PR when the CLI binary changes: |
| 53 | + |
| 54 | +- **Patch** (2.0.0 -> 2.0.1): Bug fixes, internal refactors, dependency updates. |
| 55 | +- **Minor** (2.0.0 -> 2.1.0): New features, new commands, new flags, or changed behavior. |
| 56 | +- **Major**: Ask the user for confirmation before bumping the major version. |
| 57 | +- **No bump needed**: Documentation-only changes, CI config, or other changes that do not affect the compiled binary. |
| 58 | + |
| 59 | +Only bump the version once even if multiple code changes are made in the same session. |
| 60 | + |
| 61 | +## Documentation |
| 62 | + |
| 63 | +- Update `README.md` when code changes affect user-facing behavior, CLI usage, or flags. |
| 64 | +- Keep the README focused on usage and contribution guidance. |
| 65 | + |
| 66 | +## Verification |
| 67 | + |
| 68 | +Run `make ci` before submitting any change. It runs the full pipeline: |
| 69 | + |
| 70 | +1. Lint (gofmt, go vet, golangci-lint with gocritic, misspell, and revive) |
| 71 | +2. Build |
| 72 | +3. Test (all Ginkgo suites) |
0 commit comments