goca
AGENTS.md299 starsChanged 6 months agoMITView on GitHub
Quick navigation for AI agents. Every line answers "would an agent miss this?" Entry point: doc.go — package main with func main(), calls cmd.Execute(). No main.go exists; doc.go serves both doc + entry point roles. CLI commands: cmd/*.go — Cobra subcommands. - Layer generation: entity.go, usecase.go, handler.go, repository.go - Composite: feature.go, init.go, integrate.go - Utilities: di.go, interfaces.go, messages.go, middleware.go - Supporting: config_manager.go, template_manager.go, mcp_server.go, analyze.go, ci.go, doctor.go, upgrade.go - Templates: templates.go, template_components.go, project_templates.go Goca's own demo packages (NOT generated output…
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,774 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository10 other files it gives its agents.
- .github/agents.mdAGENTS.md
- caveman-commitSkill
- cavemanSkill
- golang-patternsSkill
- golang-testingSkill
- codegen-testingSkill
- goca-architectureSkill
- mcp-toolsSkill
- ddd-teaching-skillSkill
- goca-helper-skillSkill
The file
We split this AGENTS.md into the rules it gives an agent
8 rules. About 1 is common, 4 are distinctive, and 3 are very specific to this project.
≈1
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 62
Every template change must pass for all 8 database backends (postgres, mysql, sqlite, sqlserver, mongodb, redis, cassandra, dynamodb):
- Very specific: line 70
After ANY template change: make test-cli-comprehensive.
- Distinctive: line 85
All constructors accept interfaces, not concrete types.
- Distinctive: line 93
No deletion operations in any command
- Common: line 94
No sensitive data (DB passwords) logged or surfaced in CLI output
- Very specific: line 95
All file writes go through SafetyManager.WriteFile() — never os.WriteFile directly in command code
- Distinctive: line 124
Template data must be fully populated: before rendering — missing fields → nil pointer dereference
- Very specific: line 126
Test isolation: always use t.TempDir(), never real filesystem
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md — Goca Code Generator
Quick navigation for AI agents. Every line answers "would an agent miss this?"
📁 Repo Structure
Entry point: doc.go — package main with func main(), calls cmd.Execute().
No main.go exists; doc.go serves both doc + entry point roles.
CLI commands: cmd/*.go — Cobra subcommands.
- Layer generation:
entity.go,usecase.go,handler.go,repository.go - Composite:
feature.go,init.go,integrate.go - Utilities:
di.go,interfaces.go,messages.go,middleware.go - Supporting:
config_manager.go,template_manager.go,mcp_server.go,analyze.go,ci.go,doctor.go,upgrade.go - Templates:
templates.go,template_components.go,project_templates.go
Goca's own demo packages (NOT generated output — reference implementations):
internal/domain/, internal/usecase/, internal/handler/, internal/repository/, internal/di/, internal/messages/, internal/interfaces/, internal/mocks/, internal/constants/
Testing: internal/testing/ — comprehensive_test.go + suite.go + tests/ + framework/.
External rules (per-file-type): .github/instructions/ — 6 instruction files (testing, security, clean-architecture, commands, quality, docs-vitepress).
Workflow prompts: .github/prompts/ — 6 prompt templates (new-command, audit-codegen, add-tests, etc.).
Agent definition: .github/agents/goca-forge.agent.md.
Reusable skills: .github/skills/ — 3 skills (codegen-testing, goca-architecture, mcp-tools).
OpenCode plugin: .opencode/package.json — @opencode-ai/plugin: 1.15.13.
Config: .goca.yaml (project defaults), .goreleaser.yml (Homebrew + multi-arch release).
🔧 Developer Commands
make dev # fmt → lint → test → build (pre-commit check)
make lint # golangci-lint run
make test # go test -v ./...
make test-coverage # → coverage.html
make build # Build binary with version injection
make install # go install . → $GOPATH/bin/gocaCLI integration tests (go run internal/testing/test_runner.go):
make test-cli-comprehensive # All CLI scenarios
make test-cli-init # goca init only
make test-cli-feature # goca feature only
make test-cli-entity # goca entity only
make test-cli-fast # Compilation-only (quick iteration)
make test-cli-quality # Code quality of generated output
make test-all # Unit + comprehensive CLI testsRun a specific test:
go test -v ./internal/testing -run TestGocaInitCommand
go test -v ./cmd -run TestValidateEntityNameVersion injection: go build -ldflags "-X github.com/sazardev/goca/cmd.Version=$(VERSION) ..."
Requires git tags. Use VERSION=dev make build if no tags exist.
🔑 Codegen Quality Gates (non-negotiable)
Every template change must pass for all 8 database backends (postgres, mysql, sqlite, sqlserver, mongodb, redis, cassandra, dynamodb):
go build ./...— zero errorsgo vet ./...— zero warningsgo fmt ./...— properly formatted- No unused imports
- Template renders with empty
Fieldsslice (edge case) - Optional features toggle on/off: timestamps, soft_delete, uuid, audit, versioning
After ANY template change: make test-cli-comprehensive.
Template data: Build TemplateData completely before passing to template.Execute. Missing fields → nil pointer dereference at runtime. All template strings are static constants — never constructed from user input.
🏛️ Architecture Rules (generated code)
Dependency direction (enforced, points inward):
HTTP Handler → UseCase Interface → Repository Interface → Domain Entityinternal/handlerimports usecase interfaces only (never concrete types)internal/usecaseimports repository interfaces (never handler)internal/domainimports nothing frominternal/- DI container is the only place that wires concrete → interface
All constructors accept interfaces, not concrete types. Business logic lives in usecases, never handlers.
🛡️ Security Validation
- Names match
^[A-Za-z][A-Za-z0-9]*$— validated viaCommandValidator - Paths:
filepath.Joinwith validated components only; verify withinos.Getwd() - Shell:
exec.Commandwith argument arrays — never string concatenation - File permissions: source
0644, dirs0755 - No deletion operations in any command
- No sensitive data (DB passwords) logged or surfaced in CLI output
- All file writes go through
SafetyManager.WriteFile()— neveros.WriteFiledirectly in command code
See .github/instructions/security.instructions.md for full OWASP checklist.
🚫 Regla Absoluta: No Bypass de Hooks
NUNCA uses --no-verify, LEFTHOOK=0, ni ningún otro mecanismo para saltar los hooks de pre-commit o pre-push.
Si un hook falla:
- Lee el error completo — identifica QUÉ herramienta falló (golangci-lint, nilaway, gosec, staticcheck, tests, build, docs)
- Investiga la causa raíz del error en el código o configuración
- Corrige el problema real — no lo escondas ni lo silencies
- Si después de investigar no sabes cómo resolverlo, PREGUNTA al usuario explicando el error y mostrando las opciones
Esta regla es estricta e inquebrantable. Ignorarla viola la confianza del proyecto.
⚡ Key Files by Task
| Task | Files |
| Template author | cmd/templates.go, cmd/template_components.go, cmd/project_templates.go |
| Command developer | cmd/entity.go, cmd/feature.go (pattern reference) |
| Test engineer | cmd/*_test.go, internal/testing/ |
| Architecture | .github/instructions/clean-architecture.instructions.md |
| Security auditor | cmd/command_validator.go, cmd/safety.go |
| MCP integration | cmd/mcp_server.go, cmd/mcp_tools*.go, cmd/mcp_resources.go |
🚨 Gotchas
- Template data must be fully populated before rendering — missing fields → nil pointer dereference
- Generated imports must match used packages — mismatch breaks
go vet - Test isolation: always use
t.TempDir(), never real filesystem - Integration tests are slow —
make test-cli-fastfor quick feedback - Version info requires git tags —
VERSION=dev make buildif no tags pre-release-checkruns:fmt → lint → test → test-cli-comprehensive- Config loading fails silently for non-init projects — always handle config load warnings
- MCP server mode —
goca mcp-serverstarts a stdio MCP server exposing Goca as tools for AI assistants
Go 1.25.1 required. Module: github.com/sazardev/goca.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

