Skip to content

AI Agent Workspace, Rules, Commands & Skills ​

Every project scaffolded from goforge-template ships with AGENT.md and .agent/ — an agent-agnostic workspace specification designed so AI coding assistants (Antigravity, Claude Code, Cursor, Codex, etc.) understand GoForge's architecture, boundaries, and workflows from the first prompt.


Workspace Layout ​

text
<project>/
├── AGENT.md                          # Master project & workflow guide for AI agents
└── .agent/
    ├── settings.json                 # Workspace metadata & default entrypoints
    ├── rules/                        # 4 binding architectural & quality rule files
    │   ├── architecture.md
    │   ├── api-design.md
    │   ├── database.md
    │   └── testing.md
    ├── commands/                     # 6 structured session & delivery workflows
    │   ├── context.md
    │   ├── next.md
    │   ├── review.md
    │   ├── ship-feature.md
    │   ├── state.md
    │   └── session-end.md
    └── skills/                       # 10 domain skills + 12 automation scripts
        ├── cli-commands/             # new-service.sh, remove-service.sh
        ├── configuration/
        ├── database-migrations/      # migrate.sh, rollback.sh, sqlc.sh
        ├── error-handling/
        ├── goforge-core/
        ├── http-grpc/                # proto.sh
        ├── limen-auth/               # scaffold.sh, install-deps.sh, migrate.sh, test-endpoints.sh
        ├── testing/                  # run.sh
        ├── tls/                      # gen-cert.sh
        └── validation/

.agent/settings.json ​

Provides machine-readable discovery paths for AI tools:

json
{
  "version": 1,
  "project": "goforge-template",
  "description": "Agent-agnostic workspace guidance for working inside the GoForge generated application template.",
  "commands_dir": ".agent/commands",
  "rules_dir": ".agent/rules",
  "skills_dir": ".agent/skills",
  "default_entrypoints": [
    "README.md",
    ".agent/commands/context.md",
    ".agent/rules/architecture.md"
  ],
  "module_path": "github.com/mmycin/goforge"
}

The 10 Non-Negotiable Rules (AGENT.md) ​

  1. No package-level mutable state in internal/ or core/.
  2. Constructor-based dependency injection — prefer New* functions wired via core/di.
  3. Imports must use <module>/boot/... or <module>/core/....
  4. Never edit boot/ or core/ — application logic belongs in internal/services/.
  5. Keep transport thin — business logic lives in service.go, not handler.go.
  6. Always validate at the handler edge using core/validator.
  7. Never write raw c.JSON(...) for errors — pass errors via _ = c.Error(appErr).
  8. Keep route registration local to the owning service package (routes.go).
  9. Run goforge migrate after any model change — schema drift causes runtime errors.
  10. internal/services/kernel.go is auto-regenerated by goforge gen:service / rem:service — use module.go so regeneration preserves your wiring.

Binding Rules (.agent/rules/) ​

Rule FileKey Constraints
architecture.mdEnforces boot/ & core/ immutability vs internal/ ownership, constructor DI, no mutable globals, and stopping to confirm if a change belongs in goforge-cli.
api-design.mdThin HTTP/gRPC transport, core/validator at handler edge, _ = c.Error(...) routed to ErrorHandler, local route registration, graceful gRPC shutdown, additive API changes.
database.mdDeliberate model updates, immediate migration awareness, safe GetGorm() error handling, keeping SQLC generated code synced with internal/database/queries/.
testing.mdRun targeted tests for touched packages first, broaden runs when startup/transport/shared wiring changes, test public behavior over internals, explicitly report unrun tests.

Agent Commands (.agent/commands/) ​

Structured workflows that an agent follows at key points in a session:

CommandPurpose & Checklist
contextSession start reading order: README.md → .agent/rules/architecture.md → .agent/rules/testing.md → target service/package.
next6-step decision order to locate the owning package (internal/services/<name>/, boot/, or core/) and prefer editing existing files.
reviewPre-merge review priority: 1. Bugs → 2. Regressions → 3. Security/config risks → 4. Missing tests → 5. Maintainability.
ship-feature5-step end-to-end delivery: read context.md → pick matching .agent/skills/ → implement smallest coherent change → update wiring/config/migrations/tests in one pass → run targeted then broad tests.
stateMaps current behavior before editing: where it is wired, what dependencies are injected, what env keys affect it, and what tests cover it.
session-endClean handoff: summarize changes, list follow-ups, record tests run/unrun, call out config/migration/deployment impact, and note any CLI template sync needed.

Agent Skills & Automation Scripts (.agent/skills/) ​

Each skill contains a SKILL.md instruction file and optional executable bash helpers:

SkillScopeIncluded Scripts
cli-commandsgoforge CLI lifecycle, scaffolding, and feature workflowsnew-service.sh <name>, remove-service.sh <name>
configurationAdding/renaming Viper settings in core/config/ and .env.example—
database-migrationsModel changes → Atlas SQL diffs → SQLC regeneration → rollbacksmigrate.sh <name>, rollback.sh, sqlc.sh
error-handling*apperrors.AppError constructors (400–503), Wrap, c.Error()—
goforge-coreboot/kernel.go, core/di, internal/services/kernel.go, app/main.go—
http-grpcGin routes, gRPC interceptors, internal/proto/<name>/<name>.protoproto.sh [name|--clean]
limen-authLimen session auth (User, Session, Verification, Account, /register, /login, /me, /logout)scaffold.sh, install-deps.sh, migrate.sh, test-endpoints.sh [base-url]
testingScoped test execution across unit/, http/, grpc/, integration/run.sh [http|grpc|integration|unit|all]
tlsHTTP/gRPC TLS config & self-signed dev certificate generationgen-cert.sh [days] [CN] (defaults: 365 days, CN=localhost)
validationvalidate: tags, core/validator.Validate, RegisterRule—

Common Skill Script Workflows ​

bash
# Scaffold a new service + generate & apply its initial migration
bash .agent/skills/cli-commands/new-service.sh billing

# Scaffold Limen authentication & install dependencies
bash .agent/skills/limen-auth/scaffold.sh
bash .agent/skills/limen-auth/migrate.sh
bash .agent/skills/limen-auth/test-endpoints.sh http://127.0.0.1:3000

# Compile gRPC proto definitions (or pass --clean to remove generated pb.go)
bash .agent/skills/http-grpc/proto.sh task

# Generate self-signed dev TLS certs (cert.pem / key.pem)
bash .agent/skills/tls/gen-cert.sh 365 localhost

# Run scoped tests
bash .agent/skills/testing/run.sh unit
bash .agent/skills/testing/run.sh all

limen-auth with DI & X-App-Key

When using limen-auth on goforge-template (d666864+), wire NewAuthService and the 4 Limen models inside internal/services/auth/module.go (as shown in Tutorial Ch. 2) and pass -H "X-App-Key: $APP_KEY" when calling endpoints.

Released under the Apache-2.0 License.