forgemap
v0.14.0
Published
CLI that manages a local repo layout grouped by git server, organization and repository name.
Maintainers
Readme
🗺️ forgemap
One consistent local layout for every repo you clone — across every forge

$ forgemap clone kirchDev/laravel-pbac
✔ Cloned kirchDev/laravel-pbac → ~/projects/comGithub/kirchDev/laravel-pbacThat's it. Every repo lands at a predictable <root>/<forge.dir>/<namespace…>/<repo> path — one namespace level on GitHub, as many as you like on GitLab — and forgemap cd <slug> jumps into any of them from anywhere: exact slug, fuzzy match, or interactive picker.
✨ Features
- 🗂️ Predictable layout — every clone goes to
<root>/<forge.dir>/<namespace…>/<repo>, configured once. GitLab subgroups nest as deeply as they do upstream. - 🚪 Flexible slug syntax —
owner/repo,forge:group/sub/repo, full HTTPS URLs (a pasted…/repo/-/merge_requests/1still resolves to the repo), or SSH (git@…:…,ssh://…). - 🔍 List & fuzzy search —
forgemap listshows every local repo,forgemap list <term>filters by owner or repo name (powered by Fuse.js);cd,pathandopentake the same fuzzy terms. - 🤖 Forge-aware —
type: 'github'shells out togh,type: 'gitlab'toglab(subgroups included);type: 'git'uses plaingit clonewith no extra dependencies. - 🔁 Mass sync + status —
forgemap syncfetches every clone in parallel,forgemap statusshows branch / dirty / ahead / behind per repo — narrow either to given owners or forges with a repeatable--filter. - 📥 Import existing trees —
forgemap import <path>adopts a folder already laid out as<server>/<owner>/<repo>, reconciles each repo against its git remote (spotting moved or deleted remotes), and derives a config. - 🧹 Safe cleanup —
forgemap cleanupdeletes long-idle clones,forgemap delete <slug>drops a single one — both only when it is clean, fully pushed, free of stashed work, and still on its remote, so nothing unbacked-up is ever lost. - 🛡️ Preflight validate —
forgemap validatechecks the config schema and required CLIs before you discover a problem mid-clone. - 🧰 YAML and JSON config — editor support through JSON Schema, parent walk-up discovery, and a global fallback.
- 🚀 Shell-friendly —
forgemap shell-init --installwires up realforgemap cd <slug>and tab-completion in one step.
📦 Install & run
[!IMPORTANT] Needs Node 24+ and
gitonPATH.gh(GitHub CLI) is only required when atype: 'github'forge is configured, andglab(GitLab CLI) when atype: 'gitlab'one is — runforgemap validatefor an exact rundown of what your config needs.
npm install -g forgemap # or: pnpm add -g forgemap
cd ~/projects # the directory that should hold all your repos
forgemap config init # write a starter forgemap.config.yaml
forgemap shell-init --install # cd wrapper + completion → your rc file (idempotent)
source ~/.zshrc # re-source once, then it's automatic
forgemap clone kirchDev/laravel-pbac # any slug form works: owner/repo, forge:owner/repo, URL, SSH
forgemap cd laravel # fuzzy match → jump in; bare `forgemap cd` opens a pickerAlready installed? forgemap self-update checks the registry, tells you which package manager owns the install, and asks before running its update command.
forgemap cd resolves the slug, walks/picks across your cloned repos, and actually changes directory because the shell wrapper from shell-init intercepts it before the binary runs. Every other subcommand falls through to the real binary unchanged. Hacking on forgemap itself? See CONTRIBUTING.md → Trying the CLI locally — covers pnpm setup, pnpm link --global . and the shell-wrapper source.
Clone & jump
forgemap clone kirchDev/laravel-pbac # default forge
forgemap clone github:TitusKirch/forgemap
forgemap clone https://github.com/foo/bar
forgemap clone https://github.com/foo/bar --ssh # SSH remote, whatever form the input takes
forgemap clone owner/a https://github.com/owner/b [email protected]:group/c.git # several at once
forgemap cd kirchDev/laravel-pbac # exact slug → direct cd
forgemap cd laravel # fuzzy single match → direct cd
forgemap cd kirch # multiple matches → interactive picker
forgemap cd # no arg → picker over every clonePrint a path — path
forgemap path kirchDev/laravel-pbac # → ~/projects/comGithub/kirchDev/laravel-pbac
forgemap path laravel # fuzzy single match → same path
cd "$(forgemap path laravel)" # the manual form of `forgemap cd`
code "$(forgemap path forgemap)" # feed any tool that takes a directoryPrints where a repo lives — or would live, if it isn't cloned yet, which makes it useful for scripting a clone target. An exact owner/repo never touches the disk, so a strict slug always wins over a fuzzy match; ambiguous fuzzy terms error with the candidate list rather than guessing.
List, search and pick on demand
forgemap list # every repo as a pretty tree
forgemap list forgemap # pretty tree (one line per match)
forgemap list forgemap | fzf # pipe-friendly path output
forgemap ls # `ls` is an alias for `list`
forgemap pick # interactive picker (consola prompt)
forgemap pick kirch # picker pre-filtered by fuzzy queryOpen the folder in the OS file manager
forgemap open kirchDev/laravel-pbac # exact slug
forgemap open laravel # fuzzy single match → same folder- WSL → launches
explorer.exeagainst\\wsl$\<distro>\…, Explorer opens the folder - macOS →
open <path>(Finder) - Linux →
xdg-open <path>
Mass operations across every clone
forgemap sync # git fetch --all --prune, 4 in parallel
forgemap sync --pull # git pull --ff-only (skips dirty trees)
forgemap sync --forge work --query api # restrict scope
forgemap status # tree: branch / dirty / ahead↑ / behind↓ / last commit
forgemap status --format json # structured for jq + scripts
# --filter keeps only matching owners/forges. Repeatable, OR-combined.
forgemap status --format json --filter kirchDev --filter TitusKirch
forgemap status --no-cache # rescan the disk instead of using the cached tree--filter works on status, sync and list. It matches an owner or a forge name exactly (case-insensitive) — unlike --query, which is fuzzy.
status, sync and cleanup read a cached repo tree so repeated runs stay fast. Pass --no-cache to skip it and walk the disk again — the cache refreshes on its own, so you only need this right after cloning or moving repos by hand.
All tree output (status, list, import) groups as forge → owner → repo. Network operations (sync, import, cleanup) run with a hard timeout and non-interactive SSH, so an unreachable host can never wedge a run.
Adopt an existing layout — import
Already have a folder full of repos laid out as <server>/<owner>/<repo>? Adopt it without re-cloning:
forgemap import ~/projects # reconcile + derive/write forgemap.config.yaml
forgemap import ~/projects --no-remote-check # offline: folder-vs-origin only (instant)
forgemap import ~/projects --fix # move folders / fix origin URLs to match the remote
forgemap import ~/projects --no-write-config # only report, don't touch the config
forgemap import ~/projects --format jsonFor each repo import compares the folder's <namespace…>/<repo> against the git origin, checks whether the remote still exists or was moved/renamed (GitHub and GitLab via a batched gh / glab GraphQL query, plain git forges via git ls-remote), and derives root + one forge per server directory. Read-only by default — --fix is the only thing that touches the filesystem.
Reclaim disk — cleanup
forgemap cleanup # list deletable clones, then type "yes" to confirm
forgemap cleanup --dry-run # show candidates + why every other idle repo is kept
forgemap cleanup --days 540 # idle threshold in days (default 365)
forgemap cleanup --include-dirty --include-unpushed --include-stashed # also delete repos with local-only work (lost!)A repo is only deleted when it is idle for --days+ days (by last local commit), has a clean working tree, has nothing unpushed, has no stashed work, and its remote still exists — so everything removed is provably backed up. Repos without a remote (or with a gone/unreachable one) are never touched; empty owner directories left behind are pruned automatically. Both deletion commands inspect linked worktrees for uncommitted changes and detached HEADs for unpushed commits. External worktrees require --include-worktrees, which removes them through Git. Dirty or unpushed work still requires its own override. An unreadable worktree blocks deletion. Deletion needs an explicit typed yes (or --yes).
Drop one repo — delete
forgemap delete kirchDev/laravel-pbac # gates, then type "yes" to confirm
forgemap delete github:foo/bar # forge-qualified slug or full URL
forgemap delete foo/bar --dry-run # report the gates; never prompt or delete
forgemap delete foo/bar --yes # non-interactive (scripts)
forgemap delete foo/bar --include-dirty --include-unpushed --include-stashed # delete local-only work too (lost!)The targeted counterpart to cleanup: same safety gates, no staleness requirement — for the repo you are done with today. It runs the identical checks (clean tree, nothing unpushed, no stashed work, remote still exists) and prints the local-only work at stake, naming the branches that carry unpushed commits and the stash count rather than just saying "unpushed". A gone or unreachable remote is a hard stop that no flag overrides — that local copy may be the only one left. After deleting, the repo is evicted from the scan cache and emptied owner directories are pruned.
Follow a renamed repo — move
forgemap move # the repo you are in → where its origin points
forgemap move TitusKirch/mc-network # a named repo (slug or fuzzy query)
forgemap move --all --dry-run # every repo whose folder disagrees with its origin
forgemap move --all --yes # …and move them, without the prompt
forgemap move foo/bar --agents # carry Claude Code and Codex sessions along
forgemap move foo/bar --no-remote-check # follow the local origin only, ask no forgeFor a repo that changed name or owner. If you already repointed origin by hand, move puts the folder where that origin says. If you didn't, it asks the forge (gh / glab) whether the remote moved, then repoints origin and moves the folder in one go. An ssh remote stays ssh. Linked worktrees are repaired with git worktree repair, the scan cache follows along, and emptied owner directories are pruned. A target that already exists is never overwritten.
Coding agents key their sessions by absolute path, so after a move /resume loses them. --agents carries that state along:
- Claude Code: renames the session folders under
~/.claude/projects/(worktrees below the repo included, sibling repos sharing a name prefix excluded) and moves the project entry in~/.claude.json.CLAUDE_CONFIG_DIRis honoured. - Codex: rewrites the
cwdthatcodex resumefilters by in the session transcripts and thestate_*.sqlitethread index, and moves the trust entry inconfig.toml.CODEX_HOMEis honoured.
The message history inside transcripts is left as written. These are the tools' own undocumented formats, so close running sessions in that repo first and check with --dry-run.
Preflight your config
forgemap validate # pretty checklist with ✓ / ! / ✗ per check
forgemap validate --json | jq # machine-readable for pre-commit hooksValidates the schema, required CLI tools (git always, gh when a type: 'github' forge is configured, glab when a type: 'gitlab' one is), each CLI's auth status, that the configured root exists, and that no directory under a forge dir is sitting there without a git repo in it.
Shell integration & completion
forgemap shell-init --install # cd wrapper + completion → your rc file (idempotent)
forgemap completion --install # completion only, if you don't want the cd wrapper
forgemap shell-init # print the wrapper (manual: eval "$(…)")
forgemap shell-init fish | source # fish: source the wrapper directly
forgemap completion bash # print the completion script for bash/zsh/fish--install appends a marker-guarded block to the right rc file (~/.zshrc, ~/.bashrc, or ~/.config/fish/config.fish) — re-source it once and you're done. Tab-completion suggests every subcommand, and slugs for the commands that take one (cd, clone, open, …).
Inspect and edit the config
forgemap config init # write a starter forgemap.config.yaml
forgemap config show # print the resolved config + which file it came from
forgemap forge add work --type gitlab --host gitlab.acme.com --dir comGitlabAcme
forgemap forge edit work --host gitlab.example.com # change one field
forgemap forge remove work # drop a forge from the config
forgemap info # version, binary path, node and resolved config (--json)forge add prompts for anything you don't pass. With more than one config file on the walk-up path, forge asks which one to change (or take --config <path>).
Update forgemap itself — self-update
forgemap self-update # version check, then type "yes" to run the update command
forgemap self-update --check # only report (exit 1 when outdated) — for a cron or a status line
forgemap self-update --print # print just the command for this install; makes no network call
forgemap self-update --json # machine-readable: current, latest, install kind, command, blockers
forgemap self-update --yes # non-interactive (scripts)forgemap does not own its own installation, so it never updates itself behind your back: it works out which package manager put it there — from the resolved binary path, the same way forgemap info does — and proposes that manager's command (npm i -g, pnpm add -g, bun add -g, yarn global add, volta install). Nothing runs until you type yes.
Five cases print the command and deliberately refuse to run it: a linked dev build (update it with git), a copy in an npx/dlx cache (thrown away after the run), a project dependency (bump it in that project's package.json), an unrecognised layout, and a target directory that isn't writable — a sudo command is never proposed, let alone run.
Global npm, pnpm, yarn and bun installs check the npm registry. Other installs check GitHub Releases. FORGEMAP_REGISTRY and FORGEMAP_REGISTRY_TIMEOUT_MS configure the npm lookup.
Interactive commands can show a cached update notice on stderr once per day. A detached process refreshes the cache under $XDG_CACHE_HOME/forgemap (default ~/.cache/forgemap). Set FORGEMAP_NO_UPDATE_CHECK=1 or NO_UPDATE_NOTIFIER=1 to disable both the notice and background refresh.
⚙️ Configuration
forgemap config init writes forgemap.config.yaml. Add entries under forges for additional servers.
# yaml-language-server: $schema=https://github.com/TitusKirch/forgemap/releases/latest/download/forgemap.schema.json
root: .
defaultForge: github
forges:
github:
type: github
host: github.com
dir: comGithub
work:
type: gitlab
host: gitlab.acme.com
dir: comGitlabAcme
other:
type: git
host: git.example.com
dir: comGitExample
protocol: sshDiscovery accepts .yaml, .yml, and .json. Keep one config file per directory. Existing TS and JS configs are deprecated. Run forgemap config migrate for YAML or forgemap config migrate --format json for JSON. Migration evaluates the module, verifies that the new file loads with the same values, and saves the original source and comments in a sibling .bak file.
The config is discovered by walking up from your current directory (so forgemap cd works from inside any clone, not just the root), then falling back to a global $XDG_CONFIG_HOME/forgemap/forgemap.config.* (i.e. ~/.config/forgemap/) so commands work from anywhere. Override with --config <path> or the FORGEMAP_CONFIG env var.
[!TIP] Already have a directory full of repos? Skip writing this by hand —
forgemap import <path>derivesroot+forgesfrom the existing layout.
| Key | What it controls |
| :------------------- | :-------------------------------------------------------------------------------------------------------- |
| root | Base directory for all clones. Relative paths resolve against the config file's directory. |
| defaultForge | Forge alias used when a slug is just owner/repo (no host or forge prefix). |
| protocol | Optional. 'ssh' or 'https' — the clone protocol for every forge without a protocol of its own. Unset, git forges clone over SSH and github / gitlab leave it to gh / glab. |
| forges.<name>.type | 'github' (shells out to gh), 'gitlab' (shells out to glab, namespaces may nest) or 'git' (plain git clone). gitea / codeberg reserved. |
| forges.<name>.host | Hostname, optionally with the web/HTTPS port (git.example.test:8443), used to map full URLs and build the clone URL. The port goes into HTTPS URLs and GITLAB_HOST, never into an SSH target — set a non-standard SSH port in ~/.ssh/config. |
| forges.<name>.dir | Subdirectory under root where this forge's clones live. |
| forges.<name>.protocol | Optional. 'ssh' or 'https' for this forge (git, github, gitlab), overriding the top-level protocol. Whatever form the slug takes — owner/repo, HTTPS or SSH URL — the clone uses it. Override per call with --ssh / --https; precedence is flag → forge → top-level. |
<root>/
└── <forge.dir>/
└── <namespace…>/ # one level on GitHub, nested GitLab subgroups
└── <repo>/Example with the default config rooted at ~/projects:
~/projects/
├── forgemap.config.yaml
└── comGithub/
├── kirchDev/
│ └── laravel-pbac/
└── TitusKirch/
└── forgemap/| Form | Resolves to |
| :---------------------------------- | :----------------------------------------------------- |
| kirchDev/laravel-pbac | Default forge, kirchDev/laravel-pbac. |
| work:team/api | Named forge work, team/api. |
| https://github.com/foo/bar | Host matched against forges[].host. |
| https://github.com/foo/bar.git | Same, .git suffix stripped. |
| [email protected]:foo/bar.git | SSH form, hostname matched against forges[].host. |
| ssh://[email protected]:2222/foo/bar | SSH URI; the SSH port is ignored and the hostname alone matches forges[].host. |
🤝 Contributing
PRs welcome. Conventional Commits required (enforced via commitlint); Husky runs lint-staged on every commit. Run pnpm check:fix before pushing — CI will catch what husky missed.
pnpm install
pnpm check && pnpm typecheck && pnpm test && pnpm build # the full CI gateEvery script is in package.json; setup and local linking in CONTRIBUTING.md. pnpm bench microbenchmarks scanRepos / cache hit / cache rebuild — tune its layout via env vars (FORGEMAP_BENCH_FORGES, FORGEMAP_BENCH_OWNERS, FORGEMAP_BENCH_REPOS, FORGEMAP_BENCH_RUNS).
🛣️ Versioning
Semantic Versioning via release-please — see CHANGELOG.md.
