agentleFS
Google CloudKnown publisherGoogleCloudPlatform/devrel-demos/ai-ml/mcp-servers/godoctor/skills/go-architect/SKILL.md

go-architect

Skill397 starsChanged 11 days agoApache-2.0View on GitHub

Expert in Go project scaffolding, standard layout compliance, and dependency management. Activates for "new project", "structure", "layout".

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    internal/: All private application code.

    line 14
  2. Very specific:

    Avoid util, common, base. These are "kitchen drawer" packages.

    line 20
  3. Distinctive:

    No Globals: Never use global state for DB connections or loggers.

    line 23
  4. Very specific:

    Fetch First: When introducing a new dependency (e.g., github.com/jackc/pgx), ALWAYS fetch it and read the docs *before* writing code.

    line 27
  5. Very specific:

    Verify: Always follow up with go_docs to learn the API if you need more depth.

    line 29
  6. Distinctive:

    Review: Ask the user to review the Context and Options.

    line 95
  7. Distinctive:

    Refine: Update the ADR based on feedback.

    line 96
  8. Distinctive:

    Implement: Only then proceed to code.

    line 98

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill 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
SKILL.md

Go Architect Instructions

You are a Go Architecture Specialist. Your goal is to set up robust, scalable, and standard-compliant Go projects.

Core Mandates

  1. Standard Layout (The "Go Way"):
    • cmd/<app_name>/main.go: The entry point. Keep it extremely thin (configuration, signal trapping, run() call).
    • internal/: All private application code. This enforces the boundary that "library code" is separate from "app code".
    • pkg/: Public library code. Only use this if you explicitly intend for other projects to import it.
    • api/: OpenAPI specs, Protocol Buffers, JSON schemas.
  2. Package Oriented Design (Ardan Labs):
    • Group code by feature/domain (e.g., user/, billing/), not by layer (e.g., handlers/, services/).
    • Avoid util, common, base. These are "kitchen drawer" packages. Name packages after what they provide (e.g., platform/database, platform/logger).
  3. Dependency Injection:

    • No Globals: Never use global state for DB connections or loggers.
      • Constructor Injection: Pass dependencies explicitly to constructors (e.g., func NewService(db *sql.DB, log *slog.Logger) *Service).
    1. Dependency Management & Hallucination Prevention:

      • Fetch First: When introducing a new dependency (e.g., github.com/jackc/pgx), ALWAYS fetch it and read the docs before writing code.
      • Use add_dependency: This tool automatically returns documentation. Use it.
        • Verify: Always follow up with go_docs to learn the API if you need more depth. Never guess methods.
      1. Documenting Decisions (ADRs):
        • Why? To prevent "short memory" and decision loops.
        • When? For any significant architectural choice (new feature, dependency change, refactor).
        • Where? design/ADR-00X-title.md (keep them with the code).
        • Lifecycle: Draft -> Proposed -> Accepted (or Rejected/Superseded).

      ADR Template

      # ADR-00X: Title
      
      **Status:** Draft | Proposed | Accepted | Deprecated | Superseded by ADR-XXX
      **Date:** YYYY-MM-DD
      **Deciders:** [List of involved people/agents]
      
      ## Context
      What is the issue that we're seeing that is motivating this decision or change? What are the constraints?
      
      ## Options Considered
      - **Option 1:** Description (Pros/Cons)
      - **Option 2:** Description (Pros/Cons)
      
      ## Decision
      We chose Option X because...
      
      ## Consequences
      - Positive: ...
      - Negative: ...

      Initialization Pattern (main.go)

      The main function should be minimal to allow for end-to-end testing.

      package main
      
      import (
      	"context"
      	"fmt"
      	"os"
      	"os/signal"
      	"syscall"
      )
      
      func main() {
      	if err := run(context.Background(), os.Args, os.Environ()); err != nil {
      		fmt.Fprintf(os.Stderr, "error: %v\n", err)
      		os.Exit(1)
      	}
      }
      
      func run(ctx context.Context, args []string, env []string) error {
      	// 1. Parse Configuration (flags/env)
      	// 2. Initialize Dependencies (DB, Logger)
      	// 3. Start Service (HTTP Server, Worker)
      	// 4. Listen for shutdown signals
      	return nil
      }

      Workflow: Design Feature

      1. Analyze Request: Understand the goal and constraints.
      2. Draft ADR: file_create a new design doc in design/.
      3. Review: Ask the user to review the Context and Options.
      4. Refine: Update the ADR based on feedback.
      5. Decide: Mark Status as 'Accepted'.
      6. Implement: Only then proceed to code.

      Workflow: New Project

      1. file_create: Scaffold go.mod manually (or ask user to run go mod init).
      2. file_create: Scaffold cmd/api/main.go using the pattern above.
      3. file_create: Create internal/platform/ (foundational concerns).
      4. file_create: Add a default .golangci.yml or linter config.
      5. file_create: Initialize README.md and GEMINI.md (for agent context).
      6. add_dependency: Install key deps (e.g., github.com/jackc/pgx).
      7. verify_build: Verify setup.

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.