agentleFS
sazardevsazardev/goca/AGENTS.md

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

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
  1. Distinctive:

    Every template change must pass for all 8 database backends (postgres, mysql, sqlite, sqlserver, mongodb, redis, cassandra, dynamodb):

    line 62
  2. Very specific:

    After ANY template change: make test-cli-comprehensive.

    line 70
  3. Distinctive:

    All constructors accept interfaces, not concrete types.

    line 85
  4. Distinctive:

    No deletion operations in any command

    line 93
  5. Common:

    No sensitive data (DB passwords) logged or surfaced in CLI output

    line 94
  6. Very specific:

    All file writes go through SafetyManager.WriteFile() — never os.WriteFile directly in command code

    line 95
  7. Distinctive:

    Template data must be fully populated: before rendering — missing fields → nil pointer dereference

    line 124
  8. Very specific:

    Test isolation: always use t.TempDir(), never real filesystem

    line 126

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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/goca

CLI 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 tests

Run a specific test:

go test -v ./internal/testing -run TestGocaInitCommand
go test -v ./cmd -run TestValidateEntityName

Version 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):

  1. go build ./... — zero errors
  2. go vet ./... — zero warnings
  3. go fmt ./... — properly formatted
  4. No unused imports
  5. Template renders with empty Fields slice (edge case)
  6. 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 Entity
  • internal/handler imports usecase interfaces only (never concrete types)
  • internal/usecase imports repository interfaces (never handler)
  • internal/domain imports nothing from internal/
  • 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 via CommandValidator
  • Paths: filepath.Join with validated components only; verify within os.Getwd()
  • Shell: exec.Command with argument arrays — never string concatenation
  • File permissions: source 0644, dirs 0755
  • No deletion operations in any command
  • No sensitive data (DB passwords) logged or surfaced in CLI output
  • All file writes go through SafetyManager.WriteFile() — never os.WriteFile directly 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:

  1. Lee el error completo — identifica QUÉ herramienta falló (golangci-lint, nilaway, gosec, staticcheck, tests, build, docs)
  2. Investiga la causa raíz del error en el código o configuración
  3. Corrige el problema real — no lo escondas ni lo silencies
  4. 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

TaskFiles
Template authorcmd/templates.go, cmd/template_components.go, cmd/project_templates.go
Command developercmd/entity.go, cmd/feature.go (pattern reference)
Test engineercmd/*_test.go, internal/testing/
Architecture.github/instructions/clean-architecture.instructions.md
Security auditorcmd/command_validator.go, cmd/safety.go
MCP integrationcmd/mcp_server.go, cmd/mcp_tools*.go, cmd/mcp_resources.go

🚨 Gotchas

  1. Template data must be fully populated before rendering — missing fields → nil pointer dereference
  2. Generated imports must match used packages — mismatch breaks go vet
  3. Test isolation: always use t.TempDir(), never real filesystem
  4. Integration tests are slow — make test-cli-fast for quick feedback
  5. Version info requires git tags — VERSION=dev make build if no tags
  6. pre-release-check runs: fmt → lint → test → test-cli-comprehensive
  7. Config loading fails silently for non-init projects — always handle config load warnings
  8. MCP server mode — goca mcp-server starts a stdio MCP server exposing Goca as tools for AI assistants

Go 1.25.1 required. Module: github.com/sazardev/goca.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.