DEV Community

Cover image for HazelJS CLI Generation Upgrade: faster scaffolding, fewer commands
Muhammad Arslan
Muhammad Arslan

Posted on

HazelJS CLI Generation Upgrade: faster scaffolding, fewer commands

The HazelJS CLI is about one thing: shipping. If you’re building APIs, realtime services, or AI features, you shouldn’t be hand-writing boilerplate or hunting for the “right” folder structure.

This release improves the generation workflow so it’s simpler, more consistent, and easier to automate in scripts and CI.

If you’re new here: start at HazelJS on hazeljs.ai, then jump into the docs at Docs.


What’s new

1) A skeleton app generator (like create-next-app)

You can now generate a minimal HazelJS application skeleton directly from the generator group:

hazel g app my-app
cd my-app
npm install
npm run dev
Enter fullscreen mode Exit fullscreen mode

This creates a clean starting project using the CLI template (or a fallback minimal structure if the template isn’t available). It intentionally does not run installs or initialize git—so it’s fast and predictable.

If you want the full interactive setup (package selection, installs, git init), hazel new is still there:

hazel new my-app -i
Enter fullscreen mode Exit fullscreen mode

Docs: CLI packageModules guide


2) “Setup” generator for every HazelJS package

HazelJS has many packages by design—core, auth, cache, workflow, data, AI, agent, RAG, messaging, and more. But adding a new capability shouldn’t start with “go read five docs and stitch code together”.

Use setup to generate a minimal starter file for any package:

# shorthand: st
hazel g setup swagger
hazel g setup kafka
hazel g setup oauth
hazel g setup @hazeljs/guardrails
Enter fullscreen mode Exit fullscreen mode

This creates a small *.setup.ts file with a ready-to-edit snippet and prints the next step (npm install @hazeljs/<package>).

Related: Controllers guideProviders guide


3) Discovery: list all generators

To see everything the CLI can generate:

hazel g --list
Enter fullscreen mode Exit fullscreen mode

If you want a machine-readable list (for scripts):

hazel g --list --list-json
Enter fullscreen mode Exit fullscreen mode

4) Consistent output + --dry-run + --json

All generators support:

  • --dry-run to preview created paths without writing files
  • --json to print a single JSON object with ok, created (paths), and optional nextSteps

Examples:

hazel g crud user --dry-run
hazel g controller users --json
hazel g setup swagger --json
Enter fullscreen mode Exit fullscreen mode

Example output (with --json):

{"ok":true,"created":["/path/to/project/src/users.controller.ts"]}
Enter fullscreen mode Exit fullscreen mode

In --dry-run --json mode you get the same shape; created lists what would be written.


Why this matters

Modern backends aren’t “just controllers.” You ship authentication, caching, background jobs, workflows, observability, and—more and more—AI primitives like agents and retrieval. The CLI’s job is to remove friction so you can:

  • start a project instantly,
  • add a new capability safely,
  • generate consistent code across a team,
  • and automate the workflow in CI.

If you try these generators and feel anything is missing, open an issue—we’re optimizing for real-world DX.

Links

Top comments (0)