In this tutorial, you will learn how to create a command-line application using typescript-effect
template in the repository. It is an opinionated template with convenient tooling.
The initialized project will be a complete development environment with the following dependencies:
This template provides:
- Effect
- ESLint (based on antfu's config)
- Build tool: tsup for bundling
- Development tools: tsx for hot-reloading, lefthook for git hooks
- Package manager: pnpm via corepack. You can easily switch to Bun
With some tweaks, you can also create a server application.
Initialize a new project
Section titled “Initialize a new project”Create a new directory for your project:
Terminal window nix flake new -t github:akirak/flake-templates#typescript-effect my-appEnter the directory:
Terminal window cd my-appAdd
.envrc
:Terminal window use flakeAllow direnv:
Terminal window direnv allowDelete the license header comment from
package.json
:// Delete this comment for this package.json to work// SPDX-License-Identifier: Unlicense{"name": "my-effect-app",...}Update the dependencies:
Terminal window pnpm updateTweak the generated configuration files to suit your preferences.
Understanding the template structure
Section titled “Understanding the template structure”The template includes a minimal example CLI application in src/main.ts
.
Key configuration files:
package.json
: Pre-configured scripts for development, building, linting, and type checkingtsconfig.json
: TypeScript configuration with Effect Language Service plugineslint.config.js
: ESLint setup using @antfu/eslint-config with Effect-specific overrideslefthook.yml
: Git hooks for pre-commit linting and pre-push type checking
Developing
Section titled “Developing”Running the example
Section titled “Running the example”The template includes a simple "hello" command that you can run:
# Run in development mode with hot-reloadingpnpm dev hello --name World
# Or run with tsx directlytsx src/main.ts hello --name World
Common development tasks
Section titled “Common development tasks”# Type checkingpnpm typecheck
# Lintingpnpm lint
# Fix linting issuespnpm lint-fix
# Run tests (when added)pnpm test
# Build the applicationpnpm build
Customizing for your needs
Section titled “Customizing for your needs”Playwright support: The flake includes optional Playwright browser testing support. Enable it by setting
enablePlaywright = true
inflake.nix
. Also uncomment the relevant section in the generated GitHub workflow.Frontend development: The ESLint config includes commented-out sections for React and TanStack Router support. Uncomment these if building a frontend application.
Tips for Effect development
Section titled “Tips for Effect development”- The template disables several ESLint rules that conflict with Effect's coding style (like
array-callback-return
andno-lone-blocks
) - The TypeScript configuration includes the Effect Language Service plugin for better IDE support
Next steps
Section titled “Next steps”- Explore the Effect documentation to learn more about the library
- Check out @effect/cli documentation for building complex CLI applications
- Add testing with vitest (already configured in package.json but the dependencies hasn't been added)