Skip to content
Back to skills

Go Layout

ASecurity

Where forge puts a project's generated config and middleware packages (internal/config and internal/middleware since v1.19.0; pkg/config and pkg/middleware before), how forge decides which a project has, the forge.yaml layout pin, and how to re-export either from your own pkg/ package so another module can import it. Use when a CLI, operator or sibling service in another module needs the typed config or the auth types, when a skill or error names pkg/config or pkg/middleware and your tree has...

  • 12 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 1, 2026
ai-agentsgoapi

Works with

  • cli
  • api
  • mcp

Security analysis

A100/100

Scanned December 1, 2026

npx -y skills add reliant-labs/forge --skill go-layout --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Go Layout?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Go Layout
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/reliant-labs-go-layout/badge)](https://www.skillsdirectory.com/skills/reliant-labs-go-layout)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: services/go-layout
description: Where forge puts a project's generated config and middleware packages (internal/config and internal/middleware since v1.19.0; pkg/config and pkg/middleware before), how forge decides which a project has, the forge.yaml layout pin, and how to re-export either from your own pkg/ package so another module can import it. Use when a CLI, operator or sibling service in another module needs the typed config or the auth types, when a skill or error names pkg/config or pkg/middleware and your tree has internal/config, or before moving a project with `forge fix internal-packages`.
---

# Config and middleware packages: where they live and how to publish them

**Config and middleware live under `internal/`, so the project's public surface stays small.** `internal/config` (the typed loader `forge generate` writes, plus `roots_gen.go` in a graph project) and `internal/middleware` (the auth interceptor, `procedures_gen.go`, the MCP tool table) are plumbing: Go keeps them importable only from inside the module, and `pkg/` is what a project promises other modules under semver. Projects scaffolded before v1.19.0 have them at `pkg/config` and `pkg/middleware` and stay there, with nothing to do, until they run `forge fix internal-packages` (playbook `migrations/v1.19.0/internal-packages`); forge reads which layout a project has from its tree, and `forge.yaml`'s `layout: {config_package: pkg/config, middleware_package: pkg/middleware}` pins either one. `forge scaffold package config` and `middleware` are refused where they would collide with these.

**Publishing them to another module.** Another module (a CLI, an operator, a sibling service) cannot import `<module>/internal/config`. A project that wants to share its typed config or the auth types re-exports them from a package of its own under `pkg/`; the package is then semver API the project owns, so export only what callers need:

```go
// pkg/config/config.go (yours)
// Package config publishes the service's typed config to other modules.
package config

import cfg "example.com/app/internal/config"

type Config = cfg.Config

var (
	Load     = cfg.Load
	Defaults = cfg.Defaults
)
```

A graph project's `roots_gen.go` exists to be imported from another module: the repo that keeps a deployment's values checks them against the binary's schema in a unit test (`for _, r := range appconfig.Roots() { r.Validate(env) }`). On the `internal/` layout that repo imports your re-export, so publish the roots too:

```go
var (
	Roots           = cfg.Roots
	RootNamed       = cfg.RootNamed
	ValidateRootEnv = cfg.ValidateRootEnv
)
```

The same shape works for middleware (`type Claims = mw.Claims`, `var GetUser = mw.GetUser`). Aliases keep one type, so a value from the re-export and the internal package are interchangeable inside the module. Forge recognises a `pkg/config` that imports `internal/config` as a re-export, not as the old layout, so it neither regenerates into it nor reports it as a half-finished move. A project still on the old layout that wants this: run `forge fix internal-packages` first, then add the re-export.

## Which layout a project has

Forge reads it from the tree, per package, so a project may have moved one and not the other: a `pkg/config` (or `pkg/middleware`) that holds forge's package stays there; otherwise the package is `internal/config` (`internal/middleware`). `forge.yaml`'s `layout:` pins either, and a pin wins:

```yaml
layout:
  config_package: pkg/config          # or internal/config
  middleware_package: pkg/middleware  # or internal/middleware
```

`config.loader_package` (the directory the typed-access lint allows to read the environment) defaults to the config package's directory. `forge scaffold package config` and `forge scaffold package middleware` are refused where they would collide with these. Moving an existing project: `migrations/v1.19.0/internal-packages`.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.