Fixing Next Forge's Init Pipeline: Bun Scripts Leak into Non-Bun Projects

The next-forge init command was rewriting package manager configuration for npm/pnpm/yarn but leaving bun-specific script tokens untouched, causing generated projects to fail outside of bun environments. A new transformation step now rewrites these scripts to match the selected package manager.
What
The init pipeline in next-forge transforms a bun-based template into projects configured for npm, pnpm, or yarn. It was updating the packageManager field, workspace config, and dependency protocols correctly, but the template's bun-specific scripts (bun --bun next, bunx, bun install) remained unchanged. This meant projects generated for npm or pnpm would fail when developers tried to run them without bun installed. The fix adds an updatePackageManagerScripts transformation step that rewrites these script tokens to their npm/pnpm/yarn equivalents.
Why it matters
This is a deterministic, reproducible CLI bug that breaks the core init workflow for non-bun users. The root cause is an incomplete abstraction: the init pipeline successfully rewrites most bun references but leaves scripts behind, creating a leaky abstraction where the template's original tooling assumptions bleed through. Fixing it ensures generated projects actually work with the selected package manager out of the box.
Who it's for
Developers using next-forge to scaffold new projects with npm, pnpm, or yarn. The fix benefits anyone who doesn't have bun installed or prefers a different package manager. This is a contributor-level fix that improves the template's robustness.
When & where
This fix is currently in draft PR #752 against the next-forge repository. It has not been merged to main yet. Testing was performed against real template package.json files for npm, pnpm, and yarn to verify zero residual bun tokens remain after transformation.
How
The solution adds a dedicated transformation function that scans package.json scripts and replaces bun-specific tokens with their package manager equivalents. For example, 'bun --bun next' becomes 'next', and 'bunx' becomes 'npx' (or the pnpm/yarn equivalent). The transform was verified with biome linting and TypeScript type checking. Full end-to-end testing of the init pipeline was not run due to environment constraints, but the core transformation logic is validated.
Takeaway
Incomplete template transformations are easy to miss because they fail silently in certain environments. By systematically checking all bun-specific tokens across package.json (not just config fields), the fix ensures the abstraction is complete. This pattern is useful for any tool that templates one package manager into another.
Building an AI agent?
I'm packaging how I ship them into one kit. Early access:
AI Agent Starter Kit →