Skip to content
amagdy46Public

About

npm create efforge: an opinionated Effect stack scaffolder where every part is replaceable

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

efforge logo: a maker's punch with ef struck through it, beside the word efforge

The maintained way to start a full-stack Effect app on Cloudflare.
Every capability is a layer you can add, see, test and upgrade.

npm version CI status MIT license

You, at the prompts A coding agent, no prompts
npm create efforge my-app
npx -y create-efforge@latest create my-app --json --preset=ai
The database card of a new project's dashboard. Left, a working demo: a New note field, an Add note button and the stored notes. Right, the code behind it: createNote in packages/core/src/notes.ts, which fails with InvalidNote on a bad title and stores the note through the Notes service. Under the demo, who can call it: any signed-in user, and sign-up is open until you close it. Below, the files to read next: service, layer, test and the AGENTS.md section.

You get a TypeScript monorepo: a TanStack Start app on Cloudflare Workers, its server side written in Effect. Its dashboard has a card per capability, a working demo beside the code behind it. Above is the database card.

It needs Node 24.11+ or 26+ and pnpm.

See it run

Terminal recording: npm create efforge my-app picks the AI preset at the first question, then writes, installs and commits the project in under ten seconds. In the new project, npx -y create-efforge add email adds the Mailer service and its dashboard card, and git diff shows the two lines it added to apps/web/src/server/layers.ts: the MailerLive import and MailerLive in AppLayer.

Then start the app from the demo (the AI preset uses D1):

cd my-app
pnpm db:migrate   # create the tables in the local D1
pnpm dev          # http://localhost:5173

With Postgres, docker compose up -d --wait comes first; create prints the steps for your stack.

The idea

In Effect, a service is a named interface your code asks for, and a layer is the code that implements it. efforge builds every server capability that way:

Diagram: the Notes interface; NotesLive implements it and is listed in AppLayer; in a test, NotesInMemory implements it instead and layer(NotesInMemory) provides it. Why your app is shaped like this, linked below, gives the same facts as a list.

Interfaces and their tagged errors (errors with a name the compiler knows, such as InvalidNote) live in packages/core. Only apps/web/src/server/cloudflare.ts reads the Worker's environment, so the rest runs in plain Node under @effect/vitest. Why your app is shaped like this walks through it, with the diagram as text.

Add, see, test, upgrade

Add. efforge add wires a capability into a project you already have. It parses each file it edits and changes the syntax tree, so your formatting and the code around the change stay as they were. It records a hash of each file it wrote, and refuses to overwrite one you changed. add email writes the Mailer service, its layer, a test and a dashboard card, and adds the layer to the app:

npx -y create-efforge add email
+import { MailerLive } from "./mailer"
 ...
 export const AppLayer = Layer.mergeAll(
 ...
+  MailerLive,
   /* efforge:layers */
 )

See. Besides the dashboard, npx -y create-efforge graph prints the layers AppLayer merges, with what each provides and needs, as Mermaid for a README or a pull request.

Test. Code asks for a service, never a layer, so a test swaps the layer. Each capability comes with a test layer and a test that uses it. From packages/core/test/notes.test.ts, in every project with a database:

layer(NotesInMemory)("createNote", (it) => {
  it.effect("stores the trimmed title", () =>
    Effect.gen(function* () {
      const note = yield* createNote("  Buy milk ")
      expect(note.title).toBe("Buy milk")
      const notes = yield* Notes
      expect(yield* notes.list).toContainEqual(note)
    }),
  )

Swap a layer to test has the rest.

Upgrade. doctor says what is wrong with a checkout and the command that fixes it. upgrade moves the project to the newest pins and templates. It changes only what it can prove is still efforge's, and lists the files of yours it kept.

npx -y create-efforge@latest doctor
npx -y create-efforge@latest upgrade --check
npx -y create-efforge@latest upgrade

Keep a project current walks a project from efforge 0.2.0 forward.

Pick your stack

The first question offers a preset, a whole stack in one choice, or each part in turn. Every answer is also a flag.

Preset Stack
saas Postgres, Drizzle, Better Auth with organizations, email and storage
ai D1, Effect SQL, Better Auth, AI with your own key, and realtime
minimal No database and no auth: the app, its layers and the dashboard

npx -y create-efforge my-app --yes --preset=saas --database=d1 takes a preset with one part changed. Or set the parts:

Part Flag values Default
Database --database=postgres (via Hyperdrive), d1, none postgres
ORM --orm=drizzle, effect-sql, none drizzle
Auth --auth=better-auth-orgs, better-auth, none better-auth-orgs
Infrastructure --infra=none (wrangler.jsonc), alchemy none
AI --ai=none, effect-ai-byok none
Extras --extras=workflows,realtime,browser,storage,email,rpc, and cluster (experimental) none

An ORM goes with a database, and auth needs one. Postgres needs Docker on your machine; D1 doesn't. --yes takes the defaults for the rest, and create ends with the command that makes the same stack again. The CLI reference has every flag.

For coding agents

Tell your agent to use efforge, or install the skill: npx -y skills add amagdy46/efforge --yes. They need create-efforge 0.3.0 or later, whose documents all carry contract: 1. --json never prompts and prints one JSON document. On failure, error.fix is a command that does what was asked, or null with the values to choose from (and, when there are several ways out, alternatives: complete commands, one per way).

npx -y create-efforge@latest create my-app --json --database=d1 --auth=better-auth
npx -y create-efforge@latest list --json --cwd my-app
npx -y create-efforge@latest info email --json --cwd my-app
npx -y create-efforge@latest add email --json --cwd my-app
npx -y create-efforge@latest graph --json --cwd my-app
npx -y create-efforge@latest doctor --json --cwd my-app

A typo, for example add emial --json --cwd my-app, prints (shortened):

{
  "contract": 1,
  "ok": false,
  "error": {
    "code": "UnknownAddon",
    "fix": "npx -y create-efforge add extras/email --json --cwd my-app",
    "suggestions": ["extras/email"]
  }
}

Then, in my-app: pnpm typecheck && pnpm check && pnpm test && pnpm build. The skill (skills/efforge/SKILL.md) says what each error means; docs/json.md is the full contract, and llms.txt lists the docs. The generated AGENTS.md gives an agent the project's layout and rules.

What you get

apps/web          TanStack Start app: routes, dashboard, shadcn/ui, Tailwind v4
packages/core     service interfaces, tagged errors, schemas, and their tests
packages/db       schema, migrations, database layer     (with a database)
infra/            alchemy.run.ts                         (infra=alchemy)
apps/browser      Playwright container image             (extras=browser)
efforge.jsonc     your stack, and a hash of each file efforge wrote
AGENTS.md         layout and rules for coding agents

With auth, every server function and every route under /api/ refuses a caller without a session. The exceptions are sign-in, the session check and the landing page's stack, listed in apps/web/src/server/public-*.json. Sign-up is open until you close it: anyone can register and then use every card, the ones that spend your AI key included. disableSignUp: true in apps/web/src/server/auth.ts closes it.

The project's README has the first deploy for its stack, and Deploy explains it. There is no telemetry.

Status

efforge is young. Cloudflare is the only runtime, add-ons can be added but not removed, and Drizzle and Alchemy are pinned to pre-releases. Only the --json output is versioned. CI builds and tests a matrix of generated stacks on every change, but no test deploys to a real Cloudflare account, so a first deploy is described, not verified. cluster is experimental, and there is no observability add-on yet: it waits for Effect's Cloudflare tracer to be published. Details: Status and limits.

Docs

All docs, in reading order; the add-on pages; the CLI reference; contributing and the changelog.

efforge is not affiliated with Effect or the Effect team. Prompts by Clack. MIT licensed.

About

npm create efforge: an opinionated Effect stack scaffolder where every part is replaceable

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages