Skip to content
Back to skills

Internal Packages

ASecurity

A new project's generated config and middleware packages live at internal/config and internal/middleware (forge v1.19.0), no longer pkg/config and pkg/middleware, so they stop being public semver API of the module. Nothing changes for an existing project: forge reads the layout from the tree, and a project whose pkg/config or pkg/middleware holds forge's package keeps generating there. It is opt-in. `forge fix internal-packages` moves both packages, rewrites every import across the module (te...

  • 12 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added December 1, 2026
ai-agentsgobashgitapifrontend

Works with

  • cli
  • api
  • mcp

Security analysis

A100/100

Scanned December 1, 2026

npx -y skills add reliant-labs/forge --skill internal-packages --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Internal Packages?

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

Security grade badge for Internal Packages
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/reliant-labs-internal-packages/badge)](https://www.skillsdirectory.com/skills/reliant-labs-internal-packages)

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: migrations/v1.19.0/internal-packages
description: A new project's generated config and middleware packages live at internal/config and internal/middleware (forge v1.19.0), no longer pkg/config and pkg/middleware, so they stop being public semver API of the module. Nothing changes for an existing project: forge reads the layout from the tree, and a project whose pkg/config or pkg/middleware holds forge's package keeps generating there. It is opt-in. `forge fix internal-packages` moves both packages, rewrites every import across the module (tests, examples, e2e, cmd, nested modules), the path mentions in yaml, Taskfile and .golangci.yml, and drops a forge.yaml `layout:` pin that holds the project on pkg/; it lists prose mentions and importers outside the module as follow-ups. A module that other modules import re-exports what they need from a pkg/ package of its own. Use when `forge project upgrade list` offers this playbook, when you want the config and middleware packages out of your public API, or when `forge generate` reports a half-finished pkg/ to internal/ move.
version: v1.19.0
detection: forge-detect internal-packages
---

# Config and middleware move under internal/ (v1.19.0)

`forge generate` writes two Go packages into every service project that are
plumbing, not API: the typed config loader (`config_gen.go`, and `roots_gen.go`
in a graph project) and the middleware package (the auth interceptor,
`procedures_gen.go`, the MCP tool table). Until v1.19.0 they were emitted at
`<module>/pkg/config` and `<module>/pkg/middleware`. In Go, `pkg/` is the
convention for what a module promises to other modules, and a module at v1 or
later owes its importers semver for everything they can import, so a loader
nobody outside the project should depend on was a promise the project never
meant to make. From v1.19.0 a new project gets `internal/config` and
`internal/middleware`, which Go lets only the module's own code import.

## Who this applies to

A project scaffolded before v1.19.0 whose `pkg/config` holds `config_gen.go` or
`roots_gen.go`, or whose `pkg/middleware` holds forge's middleware package.
(`forge project upgrade list` offers the playbook exactly there.) A project
scaffolded since has nothing to do. A library or CLI that never had either
package has nothing to do.

## It is opt-in; nothing breaks if you stay

Moving `forge_version` to v1.19.0 changes none of your files. forge decides each
package's home from the tree: a `pkg/config` that holds forge's config package
stays the config package, a `pkg/middleware` that holds forge's middleware stays
the middleware package, and every generator, lint rule and checksum follows. The
two packages resolve independently, so a project may have moved one and not the
other. There is no deprecation clock on the old layout.

Move when you want the packages out of your public API, or when you are about to
publish the module for others to import and do not want these in it.

## Steps

1. **Start from a clean tree.** The codemod replaces and moves files, so `git
   status` should show nothing, or only what you will commit with the move.

2. **See what it will do.**

   ```bash
   forge fix internal-packages --dry-run
   ```

   It prints one line per package it moves (with the number of files), each
   Go file whose imports it rewrites (the whole module, including `_test.go`
   files, `examples/`, `e2e/`, `cmd/` and nested modules under the module
   path), the yaml, Taskfile and `.golangci.yml` files whose path mentions it
   rewrites, and a `forge.yaml` `layout:` pin it would drop.

3. **Run it.**

   ```bash
   forge fix internal-packages
   ```

   It moves everything in `pkg/config` to `internal/config` and everything in
   `pkg/middleware` to `internal/middleware`, subdirectories included, so the
   files you own (`middleware.go` and its test) move with your edits. Its
   ownership records under `.forge/` follow the files. Re-running it changes
   nothing.

4. **Regenerate and prove it.**

   ```bash
   forge generate
   go build ./...
   task test
   forge lint
   ```

   `forge generate` writes `config_gen.go`, `roots_gen.go` and
   `procedures_gen.go` in their new home; a second run reports nothing to do.
   A generated file you had hand-edited is listed by the codemod: `forge
   generate` keeps refusing to overwrite it until you `--force` it or disown
   it, as it would before the move.

5. **Read what it left to you.** The codemod lists, with file and line, the
   prose it will not rewrite (a README or doc that says `pkg/config`) and any
   importer it cannot reach. Edit the prose by hand; the importers are the next
   section.

## If another module imports the old packages

`internal/` is importable only from the directory tree rooted at the module
path, so a CLI, operator or sibling service that lives in another module and
imports `<module>/pkg/config` or `<module>/pkg/middleware` stops compiling when
the packages move. The codemod rewrites importers inside the module (including
nested modules whose path is under the module path) and lists the rest.

Give those importers a public surface of your own, under `pkg/`, naming only
what they use. For the config:

```go
// pkg/config/config.go
// 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
)
```

and the same for the middleware (`type Claims = mw.Claims`, `var GetUser =
mw.GetUser`). Type aliases keep one type, so values cross between the two
packages without conversion. The other module's import line does not change.

A `pkg/config` or `pkg/middleware` that imports `internal/config` or
`internal/middleware` is recognised as such a re-export and not as the old
layout: forge writes nothing into it and the project does not look half moved.
What it exports is semver API from then on, which is the point: you choose it,
instead of getting all of generated code. If you re-export, do it after step 3
so the codemod does not move your file into `internal/`.

## Pinning a package where it is

To keep either package at its old path on purpose, pin it in `forge.yaml`:

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

Each value is exactly `internal/<name>` or `pkg/<name>`. A pin wins over what the
tree shows, which is why this playbook is not offered to a project that pinned
`pkg/` deliberately. `forge fix internal-packages` removes a pin that holds the
project on `pkg/`, since moving the packages is its job; to keep a pin, do not
run it, or restore the lines afterwards.

A `forge project new --in-place` over a repository that already has its own
`internal/config` or `internal/middleware` writes this pin for you and says so.
A project with `config.loader_package` set to a path of its own names the
package the typed-access lint allows; unset, it follows the config package. The
codemod rewrites an explicit `loader_package: pkg/config` to
`internal/config`; a value naming another package is left as it is.

## Half-finished moves

If `pkg/config` still holds the old package while `internal/config` holds
forge's generated files (or the same for middleware), the tree has both and
forge will not guess which one your code imports. `forge generate` stops and
names three ways out: finish the move with `forge fix internal-packages`,
delete the stale copy, or pin the package you mean in `forge.yaml`.

The codemod replaces a file already in `internal/config` or
`internal/middleware` only when forge can prove it is its own unedited render:
the `forge:hash` certificate embedded in the file still verifies, and
`.forge/disowned.json` does not list it. A forge file you edited or disowned,
another generator's output, or a file of your own there stops the run before
anything is written, and the codemod names each one.

## Rollback

Commit the tree before step 3 and the move is one diff to review and to undo:
discard it with `git restore .` (which also restores the ownership records
under `.forge/`) and remove the untracked `internal/config`,
`internal/middleware` and `.forge/scaffolded/internal/` entries it created
(`git clean -n` lists them), or revert the commit that holds it. The old
layout keeps working, so there is no deadline to go forward. Going back by hand
is `git mv` of each directory, a replace of the import path in the Go files, and a
`layout:` pin to `pkg/` so the next `forge generate` agrees.

## Not affected

- forge's own libraries, `github.com/reliant-labs/forge/pkg/config` and
  `github.com/reliant-labs/forge/pkg/middleware` (aliased `forgeconfig` and
  `fmw`), do not move. Only the packages in your own module do.
- `pkg/app` and every other path under your module are untouched.
- Generated Go in `gen/`, `internal/db` and the frontend never imported these
  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.