\n- PascalCase for fields (e.g., `Email`, `CreatedAt`)\n- Length: 1-50 characters per field name\n\n**Auto-generated fields:**\n- `ID` (uint, primary key, auto-increment) — always added\n- `CreatedAt`, `UpdatedAt` (time.Time) — with `--timestamps`\n- `DeletedAt` (gorm.DeletedAt) — with `--soft-delete`\n\n---\n\n## Error Tracing \u0026 Debugging\n\n### Common errors and solutions\n\n| Error | Cause | Fix |\n|-------|-------|-----|\n| `--fields flag is required` | Missing required fields | Add `--fields \"Name:type\"` |\n| `invalid entity name` | Name doesn't match regex | Use PascalCase alphanumeric only (`^[A-Za-z][A-Za-z0-9]*
) |\n| `invalid field format: ...` | Wrong field syntax | Use `Name:type` pairs separated by commas |\n| `file already exists` | Conflict with existing file | Add `--force` to overwrite, or `--backup` to backup first |\n| `entity already exists` | Duplicate entity name | Use different name or `--force` |\n| `unknown database type` | Invalid `--database` | Use one of: postgres, postgres-json, mysql, mongodb, sqlite, sqlserver, elasticsearch, dynamodb |\n| `unknown handler type` | Invalid `--type` | Use one of: http, grpc, cli, worker, soap |\n| Go build fails after generation | Missing deps or imports | Run `go mod tidy` then `go build ./...` |\n\n### Debug workflow\n```bash\ngoca doctor # 1. Check project health\ngoca doctor --fix # 2. Auto-fix missing dirs\ngoca analyze # 3. Deep analysis\ngoca analyze --quality # or just quality checks\ngoca analyze --security # or just security checks\ngoca analyze --output json # machine-readable output\n```\n\n### Safety first (always available on generation commands)\n```bash\ngoca feature User --fields \"...\" --dry-run # preview without creating\ngoca feature User --fields \"...\" --force # overwrite existing\ngoca feature User --fields \"...\" --backup # backup before overwrite\ngoca feature User --fields \"...\" --dry-run --force --backup # combine safely\n```\n\n---\n\n## Flag Reference by Command\n\n### `goca feature \u003cname\u003e` — Full feature generation\n| Flag | Shorthand | Default | Description |\n|------|-----------|---------|-------------|\n| `--fields` | `-f` | **required** | Entity fields |\n| `--database` | `-d` | `postgres` | postgres, mysql, mongodb, sqlite, sqlserver, elasticsearch, dynamodb |\n| `--handlers` | | `http` | http, grpc, cli, worker, soap |\n| `--validation` | | `false` | Include validations |\n| `--business-rules` | `-b` | `false` | Business rule methods |\n| `--integration-tests` | | `false` | Generate integration tests |\n| `--mocks` | | `false` | Generate testify mocks |\n| `--cache` | `-c` | `false` | Redis cache decorator |\n| `--dry-run` | | `false` | Preview only |\n| `--force` | | `false` | Overwrite existing |\n| `--backup` | | `false` | Backup before write |\n\n### `goca entity \u003cname\u003e` — Domain entity\n| Flag | Shorthand | Default | Description |\n|------|-----------|---------|-------------|\n| `--fields` | `-f` | **required** | Entity fields |\n| `--validation` | | `false` | Include Validate() method |\n| `--business-rules` | `-b` | `false` | Business rules (IsAdult, IsExpensive, etc.) |\n| `--timestamps` | `-t` | `false` | CreatedAt + UpdatedAt |\n| `--soft-delete` | `-s` | `false` | DeletedAt field |\n| `--tests` | | `true` | Unit tests |\n| `--dry-run` / `--force` / `--backup` | | `false` | Safety flags |\n\n### `goca usecase \u003cname\u003e` — Business logic\n| Flag | Shorthand | Default | Description |\n|------|-----------|---------|-------------|\n| `--entity` | `-e` | **required** | Associated entity name |\n| `--operations` | `-o` | `create,read` | create, read, update, delete, list |\n| `--dto-validation` | `-d` | `false` | DTOs with validation |\n| `--async` | `-a` | `false` | Async operations |\n\n### `goca handler \u003centity\u003e` — Protocol adapter\n| Flag | Shorthand | Default | Description |\n|------|-----------|---------|-------------|\n| `--type` | `-t` | `http` | http, grpc, cli, worker, soap |\n| `--validation` | | `false` | Input validation |\n| `--swagger` | `-s` | `false` | Swagger docs (HTTP only) |\n\n### `goca repository \u003centity\u003e` — Persistence\n| Flag | Shorthand | Default | Description |\n|------|-----------|---------|-------------|\n| `--database` | `-d` | `\"\"` | postgres, mysql, mongodb, sqlite, sqlserver, elasticsearch, dynamodb |\n| `--interface-only` | `-i` | `false` | Interface only |\n| `--cache` | `-c` | `false` | Cache layer |\n| `--transactions` | `-t` | `false` | Transaction support |\n\n### `goca di` — Dependency injection\n| Flag | Shorthand | Default | Description |\n|------|-----------|---------|-------------|\n| `--features` | `-f` | **required** | Comma-separated feature names |\n| `--database` | `-d` | `postgres` | Database type |\n| `--wire` | `-w` | `false` | Use Google Wire |\n\n### `goca middleware \u003cname\u003e` — HTTP middleware\n| Flag | Default | Description |\n|------|---------|-------------|\n| `--types` | `cors,logging,recovery` | cors, logging, auth, rate-limit, recovery, request-id, timeout |\n\n---\n\n## Template System\n\n### Built-in templates (in `cmd/templates.go`):\n- `entityTemplate` — Entity struct + validation + methods\n- `useCaseTemplate` — Interface + service + DTOs\n- `repositoryTemplate` — Interface + DB implementation\n- `handlerTemplate` — HTTP handler with CRUD\n\n### Custom templates:\n```bash\ngoca template init # creates .goca/templates/ with defaults\ngoca template list # shows available custom templates\n```\nCustom `.tmpl` / `.tpl` files override built-in templates.\n\n### Template functions available:\n`title`, `lower`, `upper`, `camel` / `toCamelCase`, `pascal` / `toPascalCase`, `snake` / `toSnakeCase`, `kebab` / `toKebabCase`, `plural` / `toPlural`, `singular` / `toSingular`, `join`, `split`, `contains`, `hasPrefix`, `hasSuffix`, `trimSpace`, `replace`, `replaceAll`\n\n---\n\n## MCP Integration (AI Tool Calling)\n\nGoca can run as an MCP server for AI assistants:\n```bash\ngoca mcp-server --print-config vscode # VS Code config snippet\ngoca mcp-server --print-config claude # Claude Desktop config\ngoca mcp-server --print-config cursor # Cursor config\ngoca mcp-server --print-config zed # Zed config\n```\n\n### Available MCP tools (5 core + 11 utility):\n\n**Core generation tools (auto-adds `--no-interactive`):**\n- `goca_feature` — name, fields, database, validation, business_rules, handlers, integration_tests, mocks, dry_run, force\n- `goca_entity` — name, fields, validation, business_rules, timestamps, soft_delete, tests, dry_run, force\n- `goca_usecase` — name, fields, validation, dry_run, force\n- `goca_repository` — name, database, dry_run, force\n- `goca_handler` — name, type, validation, dry_run, force\n\n**Utility tools:**\n`goca_di`, `goca_integrate`, `goca_interfaces`, `goca_messages`, `goca_mocks`, `goca_init`, `goca_doctor`, `goca_upgrade`, `goca_ci`, `goca_middleware`, `goca_analyze`\n\n---\n\n## Quick Reference Card\n\n### Most common command patterns\n```bash\n# New project\ngoca init \u003cname\u003e -m \u003cmodule\u003e\n\n# Quick full feature\ngoca feature \u003cName\u003e -f \"field:type,field2:type2\" -d \u003cdb\u003e\n\n# Add to existing\ngoca entity \u003cName\u003e -f \"...\"\ngoca integrate --all\n\n# Validate\ngoca doctor \u0026\u0026 goca analyze\n\n# Safety\n\u003ccommand\u003e --dry-run # preview\n\u003ccommand\u003e --dry-run --force --backup # safe overwrite preview\n```\n\n### Naming conventions\n- Entities: PascalCase (`User`, `ProductOrder`)\n- Files: snake_case (`user.go`, `product_order.go`)\n- Packages: lowercase (`domain`, `usecase`)\n\n### Database types available\n`postgres`, `postgres-json`, `mysql`, `mongodb`, `sqlite`, `sqlserver`, `elasticsearch`, `dynamodb`\n\n### Handler types available\n`http`, `grpc`, `cli`, `worker`, `soap`\n\n### Operations for usecase\n`create`, `read`, `update`, `delete`, `list`\n","repo_fullName":"sazardev/goca","repo_stars":200,"repo_language":"Go","repo_license":"MIT","repo_pushedAt":"2026-05-26T19:46:35Z","owner_login":"sazardev","owner_type":"User","owner_name":"Omar Flores Salazar","owner_avatarUrl":"https://avatars.githubusercontent.com/u/66286300?v=4"}};