Skip to content

Build with the vibelang CLI

vibelang replaces tsc. It checks .vibe, .vibex, and .ts files as one program, emits JavaScript and compatibility declarations, and accepts TypeScript's compiler flags. Install the packages with Add VibeLang to an existing project first.

  • Missing runtime: If emitted code needs vibelang-runtime and it cannot be resolved, compilation reports one TS2307 naming vibelang-runtime (independent source errors still report).
  • TypeScript 7 options: Removed options like moduleResolution: "node" / "node10" and baseUrl report TS5108 / TS5102 (TypeScript 7 migration notes).
  • Cancellation & startup: SIGINT/SIGTERM exits non-zero and prints vibelang: compilation cancelled. Exporting main adds no startup call — invoke a top-level runner explicitly.
  • Formatting: Use vibelang format --write / --check (--help lists options; see Format with dprint). Existing literal paths (quote globs like 'src/[id]/page.vibe') take precedence over glob expansion; missing files, unmatched globs, or combining --check and --write fail before modifying anything.

1. Configure tsconfig.json

VibeLang discovers vibe.config.json, tsconfig.json, then jsconfig.json per directory. vibe.config.json accepts every tsconfig field plus a top-level "vibe" object. Starter config for Node ESM:

{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "strict": true,
    "sourceMap": true,
    "rootDir": "src",
    "outDir": "dist",
    "noEmitOnError": true,
    "rewriteRelativeImportExtensions": true,
    "skipLibCheck": true,
    "types": []
  },
  "include": ["src/**/*.vibe"]
}
  • Include & discovery: A directory entry ("src") selects .vibe files; a glob like "src/**/*.ts" needs "src/**/*.vibe" beside it. Wildcard discovery prefers .ts, .tsx, .vibe, .vibex before .d.ts and .js.
  • Paths & scope: ${configDir} resolves to the extending project's config directory. Every .vibe file is always a module regardless of moduleDetection. Top-level await follows ES module/target rules (TS1378/TS1309). Standalone services without a package name need an explicit static readonly key.

Inspect or initialize configuration

CommandBehavior
vibelang --initCreates TypeScript's generic tsconfig.json (set "type": "module" in package.json for ESM and adapt include/output options).
vibelang --showConfigPrints effective inherited JSON config (including "vibe") without compiling; config errors fail exit status, warnings keep JSON output intact. Use -p for another project.
vibelang --noEmit --module nodenext --target es2022 src/hello.vibeChecks explicit files directly, bypassing config discovery (--ignoreConfig is optional; combining file arguments with -p/--project is an error).

Diagnostic severities

TypeScript's own lexical, syntax and static errors keep their TS codes, including errors inside embedded expressions and types. VibeLang's productions, placement rules and adopted proposal restrictions use the owning VIP's EK codes, regardless of the parser helper used. A specific diagnostic takes priority for the same rejection; independent native errors still report.

Configure warning codes and assigned imported EK38xx lint codes under vibe.severities ("error", "warning", "suggestion", or "off"; keep leading zeroes like EK0508):

{ "vibe": { "severities": { "EK0508": "off", "EK0801": "error", "EK4609": "off", "EK3801": "warning" } } }
  • Validation & extends recovery: extends merges vibe by key and severities by code (left to right for array bases; child wins). Severity entries are validated after merging: invalid effective entries report EK3006 and are ignored as overrides while valid entries still apply. An invalid child entry does not restore the displaced base entry for that code (lower-precedence Effect language-service config or the rule's default applies instead). Unknown or wrong-typed vibe keys report EK3007. Context-dependent error/warning codes like EK4402 are nonconfigurable.
  • Exit behavior: VibeLang's own warnings print without failing builds or noEmitOnError (set "error" to fail CI); own "suggestion" entries appear only in the language server. Imported EK38xx warnings fail builds by default (see Lint Effect code).
  • Legacy maps: Root vibelang.diagnostics and compilerOptions.vibelang.diagnostics are recognized in vibe.config.json, tsconfig.json, jsconfig.json, and extended configs. Their supported legacy settings keep applying until migrated, with modern vibe.severities entries (or explicitly mapped ports, e.g. EK4801 → EK3801, EK4823 → EK38123) taking precedence. Each legacy map warns with EK3009 ("off" hides the warning while leaving legacy settings active). An explicit child legacy section replaces the inherited one whole (an empty object or null clears inherited legacy entries while leaving modern vibe settings intact). Plain tsc rejects compilerOptions.vibelang with TS5023.
  • Retired keys: declarationImportStyle (EK3011) and trustedPackages (EK3010) are ignored with deprecation warnings; remove them.

An import a declaration file adds, such as import { Effect } from 'effect' for a file that writes number!!, takes the quotes of the file's first written import or export specifier, as an import the TypeScript language service adds does; a file with none gets double quotes. Module types written through the file's own import keep that import, and an added Effect joins it. Public .d.ts output rewrites .vibe/.vibex re-export specifiers to .ts/.tsx, while adjacent .d.vibe.ts keeps .vibe.

Experimental features

Open proposals (VIPs 55–73: task, workflow, and Experimental.Durable, Human, Eval, Scorer, Memory, Fuzz, FuzzSimulation, Test, Patterns) require opting in:

{ "vibe": { "experimental": ["builtins"] } }

Without this opt-in, the first use (including aliases, destructuring, typeof, re-exports, or subpath import()) reports EK3013. VIP-33 platform modules (Experimental.FileSystem, Experimental.Encoding, etc.) are core and need no opt-in. Invalid values report EK3007; a child experimental array replaces its base's.

2. Replace tsc in the scripts

vibelang in place of tsc

Replace tsc with vibelang in package.json:

{
  "scripts": {
    "build": "vibelang",
    "start": "vibelang && node --enable-source-maps dist/main.js",
    "test": "vitest run"
  }
}
  • Build modes: vibelang checks and emits; vibelang --noEmit only checks; vibelang --watch rebuilds when a compilation input of the selected project changes; vibelang -b builds project references. For monorepos, watch the reference graph with:
vibelang -b -w packages/app
  • Upgrading existing .vibe code: Replace stale ./Leaf.ts imports pointing at Leaf.vibe with ./Leaf.js or ./Leaf.vibe (Migrating retired forms); use (try Users).find(id) for service members and try FileSystem.FileSystem without (); run try yieldNow (or try Effect.yieldNowWith(priority)); use PlatformError.PlatformError for the failure type; and run Effects passed to plain generics explicitly (expect(try awaited())) when EK4802 fires.

Lint Effect code

Effect's lint rules in vibelang lint

vibelang runs Effect's type-aware effecttsgo/* rules from @effect/tsgo inside the compiler, language server, and vibelang lint on selected .ts and .vibe inputs (VIP-38), keeping the pinned upstream rule/file eligibility and declaration/library exclusions. VibeLang-specific language checks remain confined to .vibe. Configure rules via the repository's existing Effect language-service configuration in tsconfig.json (enabled in the starter):

{
  "compilerOptions": {
    "plugins": [{ "name": "@effect/language-service", "diagnosticSeverity": { "unstableApiUsage": "off" } }]
  }
}
{
  "scripts": {
    "lint": "vibelang lint -p tsconfig.json"
  }
}
  • CLI & options: vibelang lint accepts compiler options (-p/--project, file args) and ignores .oxlintrc.json / oxlint.config.ts. Unsupported flags (--config, -c, --deny-warnings, --ignore-path, --ignore-pattern, --no-ignore) report TS5023. vibelang lint never writes or deletes files (--build --clean and --init run as dry-runs). It exits 1 on errors (never on warnings alone).
  • Exit codes & loaders: Imported Effect warnings fail vibelang builds and block noEmitOnError by default (unless ignoreEffectWarningsInTscExitCode: true is set; similarly for ignoreEffectErrorsInTscExitCode, includeSuggestionsInTsc, and ignoreEffectSuggestionsInTscExitCode). Module loaders (vibelang/register, vibelang/bun, bundler plugins) and vibelang/project print warnings without failing loads. NodeRuntime.runMain and @effect/vitest's it trigger unstableApiUsage (EK38130); lazyEffect (EK3858) suggests a constant for exported zero-arg effect functions.
  • Rules & directives: vibe.severities overrides rules of the resolved plugin (it does not enable an absent plugin or override diagnostics: false / diagnosticSeverity: null). Use // @effect-diagnostics-next-line schemaSync:off for line overrides. See Effect language service rules and the imported lint diagnostic reference.
  • Bridging throwing helpers (EK0402/EK0403): Wrap throwing TS helpers (including void validators) with Effect.orDie(Effect.try({ try: () => check(), catch: (e) => e })) or Effect.orDie(Effect.tryPromise({ try: (signal) => fetchPage(signal), catch: (e) => e })) rather than mislabeling them @nothrow.

3. Compile a first module

Create src/hello.vibe:

// src/hello.vibe
export effect function hello(name: string) {
  return `Hello, ${name}!`
}
// Run in an effect function: try Console.log(try hello("VibeLang"))
// Output: Hello, VibeLang!

Run npx vibelang to emit dist/hello.js and adjacent .d.vibe.ts declarations (written even with --noEmit). Import local .vibe files by source name (./hello.vibe) with rewriteRelativeImportExtensions (which rewrites them to ./hello.js on emit; .ts importers in CLI builds can also write ./hello.js, whereas Vite/Vitest use ./hello.vibe — see Vite setup).

Module resolution & .vibex

ImportSource lookup order
./App, ./App.jsApp.ts, App.tsx, App.vibe, App.vibex
./App.jsxApp.tsx, App.ts, App.vibex, App.vibe
./App.vibeApp.vibe, App.vibex
./App.vibexApp.vibex, App.vibe
  • Source extensions: Importing a live .ts/.tsx/.vibe/.vibex source requires allowImportingTsExtensions or rewriteRelativeImportExtensions (otherwise TS5097; allowArbitraryExtensions applies only to declaration sidecars).
  • JSX (.vibex): Emits .jsx/.jsx.map under jsx: "preserve" and .js/.js.map in other JSX modes (inline module view { ... } bodies follow the same rule as main.vibex.view.jsx/.js). Malformed JSX reports TypeScript syntax errors rather than trailing-block EK1101.
  • Legacy trailing blocks (EK1101): Rewrite explicitly as effect { ... } (Effect program), effect () => { ... } (Effect callback), or () => { ... } (plain callback) depending on execution semantics.

4. Add an entry point

Create src/main.vibe:

// src/main.vibe
import * as NodeRuntime from "@effect/platform-node/NodeRuntime"
import { hello } from "./hello.vibe"
 
export effect function main() {
  try Console.log(try hello("VibeLang"))
}
NodeRuntime.runMain(main())
// Output: Hello, VibeLang!

Run npm run start or bun run start:

Hello, VibeLang!

Keep reusable functions in separate modules so importing them does not start the runner.

5. Test with Vitest

Avoid # in the absolute project path (Vitest 5.1.0 fails to resolve test modules under paths containing #). Create vitest.config.ts and src/hello.test.vibe:

// TypeScript (.ts)
// vitest.config.ts
import { defineConfig } from "vitest/config"
import vibelang from "vibelang-vite"
 
export default defineConfig({
  plugins: [vibelang()],
  test: { include: ["src/**/*.test.vibe"] }
})
// src/hello.test.vibe
import { assert, it } from "@effect/vitest"
import { hello } from "./hello.vibe"
 
it.effect("says hello", () => effect {
  const message = try hello("VibeLang")
  try Effect.try(() => assert.strictEqual(message, "Hello, VibeLang!"))
})

Run npx vitest run:

 Test Files  1 passed (1)
      Tests  1 passed (1)

Let TypeScript tools read .vibe modules

Stock tsc, tsrs, TypeDoc, and other TypeScript checkers cannot read .vibe directly, so vibelang emits compatibility declarations (src/greet.d.vibe.ts plus a forwarding src/greet.d.ts, and src/main.vibe.parse.d.ts for inline module parse bodies) on every build, --watch, -b, and --noEmit (VIP-27, VIP-40; rewritten only on change). The retired declarationSidecars option is an error — remove it.

  • Stock TypeScript configuration: Enable allowArbitraryExtensions in any non-vibelang project:
{ "compilerOptions": { "allowArbitraryExtensions": true } }

Without it, importing ./greet.vibe in stock tsc reports TS6263. For .ts importers using ./greet.js, ./greet, or ./greet.ts, the compiler also emits a forwarding greet.d.ts (never overwriting a hand-written .d.ts — it reports TS5055 instead):

export * from "./greet.vibe";
export { default } from "./greet.vibe";
  • Declaration surface: Published declarations retain the corresponding TypeScript class surface: generated matcher members and runtime reference directives are not added. Generated matchers remain in JavaScript; VibeLang consumers load the protocol from their own runtime prelude. schema JSDoc emits on the constant only; cyclic inferred types use /*elided*/ any rather than TS 7.1 TS5088 (Declaration output).
  • Unprintable exports: In projects with declaration or composite, unprintable types (TS4094, TS2883) are errors. In projects with neither, sidecars may reference node_modules paths. What it still cannot print there, such as TS4094, is an error only where a .ts file of the project imports the module, as for the same TypeScript under tsc, since that file reads the sidecar: it is reported at that import.
  • Bun checking: When a check script is declared, bun check runs the project's check script; a script that invokes a TypeScript checker uses that checker's sidecar resolution. bun check --no-script (Bun 1.4.4+) invokes Bun's native checker, which the runtime preload does not replace; use vibelang -b or "check": "vibelang -b" for native .vibe checking.
  • Ordering: Stock checkers read only sidecars and do not check .vibe bodies — run vibelang first:
vibelang --noEmit && tsrs -b

Keep the sidecars in one directory

Set vibe.sidecarDir (and add it to rootDirs) to keep generated sidecars out of src/ (e.g. for tools that glob *.ts):

{
  "compilerOptions": { "allowArbitraryExtensions": true, "rootDir": ".", "rootDirs": [".", ".vibe/declarations"] },
  "vibe": { "sidecarDir": ".vibe/declarations" }
}

src/greet.vibe emits .vibe/declarations/src/greet.d.vibe.ts (mirrored under rootDir or inferred source root; use ${configDir}/.vibe/declarations in shared base configs, and keep the directory inside the package for node_modules resolution). Switching vibe.sidecarDir on or off prunes unchanged sidecars owned solely by this project (tracked via hidden .vibelang-sidecar-*.owner receipts — ignore them in VCS alongside .vibe/declarations/). Do not list sidecars explicitly in files (they are outputs and would trigger TS5055).

Run sources with Node

Load the vibelang/register hook to run .ts/.vibe sources directly without building dist/:

node --import vibelang/register src/start.ts

You can also call import "vibelang/register" in TypeScript config files. .vibex works when jsx emits JS (react-jsx, react-jsxdev, react); under jsx: "preserve", Node reports ERR_VIBELANG_JSX (use Bun or a bundler instead).

  • Resolution & caching: Compiles using the nearest config (vibe.config.json → tsconfig.json → jsconfig.json), enables the vibelang-source export condition, supports extensionless imports, require()/createRequire(), and caches on disk (invalidated on source, config, dependency, or compiler changes; sidecar changes do not invalidate). Configure with VIBELANG_CACHE_DIR, VIBELANG_DISABLE_CACHE=1, and VIBELANG_REGISTER_DEBUG=1. Failed checks leave existing sidecars intact.
  • Playwright: Preload via NODE_OPTIONS (also reaches child Node processes and bare node src/main.vibe; pass --config playwright.config.vibe for a .vibe config and keep .spec.ts test files):
NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--import=vibelang/register" npx playwright test
  • Programmatic tools (vibelang/source, vibelang/project):
import { readFileSync } from "node:fs"
import { listSources, resolveSource } from "vibelang/source"
 
const files = listSources("snippets")
const file = resolveSource("snippets/example.ts")
if (file === undefined) throw new Error("Missing snippet")
const text = readFileSync(file, "utf8")

listSources(dir) returns sorted immediate .ts/.tsx/.vibe/.vibex files (excluding sidecars and virtual NUL-byte IDs). resolveSource(file) falls back from an absent .ts/.tsx to its .vibe/.vibex sibling. compileProjectSync and projectBackend().compile(project) (vibelang/project) check all project inputs (call await close() when done).

Run sources with Bun

Use Bun 1.4.2 or later for the runtime loader (1.3.13/1.4.0 have resolver and Unicode bugs). Preload vibelang/bun in bunfig.toml (or --preload vibelang/bun):

preload = ["vibelang/bun"]
 
[test]
preload = ["vibelang/bun"]
  • Resolution & features: Compiles .vibe and .vibex (forwarding preserved JSX to Bun's JSX loader) via the nearest tsconfig (override with VIBELANG_PROJECT), supports extensionless imports, tsconfig paths, ./x.js and missing ./x.ts imports, Unicode/space/#/% filenames, CommonJS require, --define/[define], and live bindings for .vibelang/js/ exports.
  • Stack frames: A stack frame names .vibe source lines when the module's emitted JavaScript is ASCII and needs nothing from Bun's transpiler; otherwise it names the .vibe file with the line of its compiled JavaScript (Source maps: Limits). Running prebuilt bun dist/main.js leaves frames unmapped — use node --enable-source-maps dist/main.js (Debug stack traces).
  • Computed dynamic imports: Use relative/absolute source paths (const p = "./src/feature.vibe"; await import(p)). Computed bare aliases to migrated .vibe siblings require literal imports; for computed extensionless bare aliases, Bun does not invoke runtime resolver hooks (Bun issue #40579).
  • Bun.build inside scripts/tests: vibelang/bun does not hook Bun.build; install vibelang-unplugin and preload vibelang-unplugin/bun/register in both preload and [test].preload (Bun build plugin).
  • Child bun test processes: bun test reads only [test].preload from its own working directory (fixture subdirectories need their own bunfig.toml) and discovers .test.ts/.test.js files (use Vitest for .test.vibe).

Watch source modules in Bun

With the vibelang/bun preload configured, bun test --watch reruns tests after an imported .vibe source changes, including through re-exports. bun --watch --preload vibelang/bun src/main.ts restarts an application after those changes. Each restart reads the changed source and reuses a cached compile only while its inputs remain unchanged. Use bun test --timeout 30000 when service-init tests exceed Bun's 5 s default.

Bun test types

Install @types/bun and enable "bun" in your test tsconfig (keeping any existing entries):

bun add -d @types/bun
{ "compilerOptions": { "types": ["bun"] } }

In bunfig.toml:

[test]
preload = ["vibelang/bun"]

Write src/greeting.test.ts and run bun test (use Effect.runPromise for async Effects):

// TypeScript (.ts)
import { expect, test } from "bun:test"
import { Effect } from "effect"
import { greeting } from "./greeting.vibe"
 
test("greeting", () => {
  expect(Effect.runSync(greeting("Bun"))).toBe("Hello, Bun!")
})

Run vibelang -p tsconfig.json for full type-checking (the preload only emits .vibe modules and reports errors in loaded .vibe files plus project-wide errors).

Upgrading legacy VibeLang code

Legacy patternCurrent VibeLang form
readonly defaults on schema / service fieldsWrite explicit readonly where needed (checking now uses shallow mutability unless marked readonly).
Empty package "name": "" service keysWrite an explicit static readonly key to retain older directory-derived keys.
f(throw error, next) (EK1010)Parenthesize before a comma: f((throw error), next).
forkIn(scope, program)Native argument order: forkIn(program, scope) (and import sync/callback explicitly when vibe.effectGlobals: false).
uninterruptible / restore outside effect code (EK2201)Remove the keyword or move into an effect block.
do { … } used as an Effect argumentWrap in effect { return do { … } }.
EK38xx in vibe.severities without plugin (EK3012)Add the @effect/language-service plugin to tsconfig.json.

Profile compilation

FlagOutput
vibelang --generateCpuProfile compiler.cpuprofileChrome CPU-profile JSON (works with --build and on error; cannot combine with --pprofDir).
vibelang --pprofDir profilesGo CPU and memory profiles (fails command on write error).
vibelang --build --generateTrace tracesWrites trace.json, types_*.json, and legend.json per compiled project under traces/project-*.
vibelang --lsp --help / --stdioInspect LSP flags or run over stdio (--pipe and --socket are reserved/unsupported).

Build-mode profile/trace paths resolve relative to the working directory.

Next

Set up your editor: VS Code and Cursor, Neovim, Zed, or other editors. Then verify with step 4 of Set up VibeLang.