Like Blockend? Give it a ⭐ on GitHub.

Star
blockend

Blockend

CLI Reference

Complete reference for the Blockend CLI — all commands, options, and usage.

The Blockend CLI (blockend-cli) is the primary interface for initializing projects, discovering and installing backend blocks, and integrating with AI coding assistants via MCP.

Installation

No global installation required. Run commands directly with npx:

npx blockend-cli <command> [options]

blockend-cli init

Initialize a blockend.json configuration for your project.

npx blockend-cli init [options]

The init command scans your project, detects your framework and package manager, and generates a blockend.json file.

Options

OptionAliasDefaultDescription
--yes-yfalseSkip prompts and use auto-detected defaults
--jsonfalseOutput machine-readable JSON instead of interactive text

Interactive Prompts

  1. Existing config handling — keep, overwrite, or regenerate if blockend.json already exists
  2. Framework selection — auto-detected or manually chosen from Express, Fastify, Next.js, Hono
  3. Blocks directory — where block files will be installed (e.g. src/blocks)
  4. Redis — enable Redis-backed variants if Redis is detected in the project
  5. Import alias — derived from tsconfig.json paths automatically

Output

Creates blockend.json in the project root:

{
  "$schema": "https://blockend.noorulhassan.com/schema.json",
  "environment": "express",
  "language": "typescript",
  "packageManager": "pnpm",
  "importRewriteStrategy": "remove",
  "includeRedis": false,
  "aliases": {
    "blocks": "@/blocks"
  },
  "paths": {
    "blocks": "./src/blocks"
  }
}

blockend-cli add <block>

Download and install a backend block into your project.

npx blockend-cli add [block] [options]

If no block name is provided, an interactive selector shows all blocks compatible with your project's framework.

Options

OptionAliasDefaultDescription
[block]Block key name (e.g. rate-limiter, logger)
--yes-yfalseSkip confirmations, auto-select first variant
--jsonfalseOutput machine-readable JSON progress

How It Works

  1. Finds blockend.json by walking up the directory tree
  2. Fetches the registry manifest from raw.githubusercontent.com
  3. Filters blocks compatible with your configured environment
  4. Prompts variant selection (e.g. memory vs Redis store) when multiple exist
  5. Installs missing npm dependencies automatically
  6. Downloads source files and writes them to the configured blocks directory
  7. Rewrites import paths according to your project's alias and strategy configuration

Variant Selection

Blocks with multiple storage backends present a variant picker:

? Select a storage variant:
❯ Memory
  Redis

If Redis is enabled in blockend.json and a Redis variant exists, it is auto-selected.

Framework Detection

The CLI checks whether a block supports your target framework using its frameworks field or adapter map. Incompatible blocks are hidden from the selector.


blockend-cli list

List available blocks for your project's framework.

npx blockend-cli list [options]

Options

OptionDefaultDescription
--jsonfalseOutput machine-readable JSON array of block metadata

Output

Shows block names, descriptions, and available storage variants:

Available backend blocks for express:

  rate-limiter
    IP-based rate limiting middleware with pluggable storage strategies
    Storage Variants: memory, redis

  logger
    Framework-agnostic context logging engine
    Storage Variants: default

blockend-cli detect

Scan the current project directory and report detected configuration.

npx blockend-cli detect [options]

Options

OptionDefaultDescription
--jsonfalseOutput full detected context as a JSON object

Detected Fields

FieldDescription
frameworkDetected backend framework
languageTypeScript or JavaScript
packageManagerDetected package manager (npm, pnpm, yarn)
srcDirWhether a src/ directory exists
importRewriteStrategyNodeNext (.js append) or Bundler (extensionless)
hasRedisWhether Redis is detected in dependencies
hasPrismaWhether Prisma is detected
hasDrizzleWhether Drizzle ORM is detected

blockend-cli mcp

Start the MCP server or initialize MCP client configuration.

npx blockend-cli mcp [command] [options]

blockend-cli mcp

Start the MCP server using the Stdio transport. This allows AI coding assistants to interact with Blockend directly.

When the MCP server is running, AI clients can call these tools:

ToolDescription
list_blocksList all available blocks with descriptions
add_blockInstall a block into a specified project
detect_projectAnalyze a project and return its configuration

blockend-cli mcp init

Generate MCP configuration files for supported AI clients.

npx blockend-cli mcp init [options]

Options

OptionAliasDefaultDescription
--clientTarget client: claude, codex, cursor, vscode, windsurf
--forcefalseOverwrite existing configuration files
--dry-runfalsePreview changes without writing to disk
--yesfalseSkip prompts, default to Claude Code

Supported Clients

ClientConfig FileFormat
Claude Code.mcp.jsonJSON
Cursor.cursor/mcp.jsonJSON
VS Code.vscode/settings.jsonJSON
Codex CLI.codex/config.tomlTOML
Windsurf.windsurf/mcp.jsonJSON

Using blockend-cli as a Package

Blockend CLI is also importable as a library:

import { addCommand } from "blockend-cli";
import { initCommand } from "blockend-cli";
import { listCommand } from "blockend-cli";
import { detectCommand } from "blockend-cli";

Each command accepts options in the same format as the CLI flags.


Exit Codes

CodeMeaning
0Success
1General error (config missing, network failure, etc.)

Environment

  • Node.js: >= 20
  • Package Manager: npm, pnpm, or yarn
  • Language: TypeScript (JavaScript support is limited)

On this page