A framework-agnostic CLI tool for managing reusable code templates. Save, manage, and apply code snippets across projects.
npm install code-brickA framework-agnostic CLI tool for managing reusable code templates. Stop copy-pasting code between projects ā save it once, use it everywhere.
Every developer has faced this workflow:
1. Create a new project (nest new my-app)
2. Open an existing project with code you want to reuse
3. Manually copy-paste files (auth module, pagination utils, config files)
4. Adjust imports, fix paths, install missing dependencies
5. Repeat for every new project
Brick eliminates steps 2-4 entirely.
``bashInstall globally via npm
npm install -g code-brick
After installation, the
brick command will be available globally:`bash
brick --version
`Quick Start
`bash
1. Initialize brick (one-time setup)
brick init2. Save a folder as a reusable template
brick save my-auth ./src/auth --description "JWT authentication module"3. View your saved templates
brick list4. Apply a template to a new project
cd ~/new-project
brick apply my-auth ./src/auth
`Commands
$3
Initialize Brick on your system. Creates the storage directory at
~/.codebrick/.`bash
brick init
`$3
Save a folder as a reusable template.
`bash
Save current directory
brick save my-templateSave a specific path
brick save nestjs-auth ./src/authWith options
brick save nestjs-auth ./src/auth \
--description "JWT authentication for NestJS" \
--tags auth,jwt,nestjs \
--detect-deps
`Options:
-
-d, --description ā Template description
- -t, --tags ā Comma-separated tags
- --include ā Glob patterns to include
- --exclude ā Glob patterns to exclude
- --detect-deps ā Auto-detect dependencies from imports$3
List all saved templates.
`bash
brick listFilter by type
brick list --local
brick list --remoteFilter by tag
brick list --tag authDetailed view
brick list --detailed
`Output:
`
# Name Type Files Description
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
0 nestjs-auth local 5 JWT authentication module
1 react-modal local 3 Animated modal with backdrop
2 docker-dev local 4 Docker Compose dev setup 3 templates (3 local, 0 remote)
`> š” Tip: Use the index number (
0, 1, 2) instead of the full name in any command!$3
Display the file structure of a template.
`bash
By name
brick tree nestjs-authBy index
brick tree 0With file sizes
brick tree 0 --size
`Output:
`
nestjs-auth
āāā guards/
ā āāā jwt.guard.ts
āāā strategies/
ā āāā jwt.strategy.ts
āāā auth.controller.ts
āāā auth.module.ts
āāā auth.service.ts5 files, 2 directories
`$3
Apply a template to your project.
`bash
Apply to current directory
brick apply nestjs-authApply by index
brick apply 0 ./src/authWith options
brick apply 0 --force --latest
`Options:
-
-f, --force ā Overwrite existing files without prompting
- --skip-existing ā Skip files that already exist
- --dry-run ā Preview changes without writing files
- --latest ā Use @latest for all dependency versions
- --no-deps ā Skip dependency installation prompts$3
Show detailed information about a template.
`bash
brick info nestjs-auth
brick info 0
`$3
Show the size of templates.
`bash
Show all template sizes
brick sizeShow specific template size
brick size nestjs-auth
brick size 0
`Output (all templates):
`
# Name Type Files Size
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
0 nestjs-auth local 5 12.4 KB
1 react-modal local 3 8.2 KB
2 docker-dev local 4 3.1 KBTotal: 12 files, 23.7 KB
`Output (single template):
`
nestjs-auth Files: 5
Directories: 2
Total Size: 12.4 KB
`$3
Add files to an existing template.
`bash
Add a single file
brick add nestjs-auth ./src/auth/dto/login.dto.tsAdd by index
brick add 0 ./src/auth/dto/*.tsAdd a directory
brick add 0 ./src/auth/decorators/
`$3
Remove files from a template.
`bash
brick remove-file nestjs-auth auth.controller.ts
brick remove-file 0 dto/
`$3
Delete a template entirely.
`bash
brick delete nestjs-authBy index
brick delete 0Skip confirmation
brick delete 0 --force
`$3
Remove local/project-specific imports from template files. This makes templates portable by stripping out imports that reference the original project.
`bash
Clean a template (auto-detects project name)
brick clean flutter-cleanBy index
brick clean 0Preview what will be removed (dry run)
brick clean 0 --dry-runUse custom pattern
brick clean 0 --pattern "package:my_app/"Also remove external packages (not recommended)
brick clean 0 --no-keep-external
`Options:
-
-p, --pattern ā Custom regex pattern to match imports to remove
- --dry-run ā Preview changes without modifying files
- --no-keep-external ā Also remove external package importsExample (Flutter/Dart):
Before cleaning:
`dart
import 'package:my_app/features/auth/login.dart';
import 'package:my_app/core/utils/helpers.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
`After
brick clean flutter-template:`dart
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
`Supported languages:
| Language | Local Imports Removed | External Imports Kept |
| --------------- | ---------------------------------- | ---------------------------------- |
| Dart/Flutter|
package:project_name/... | package:flutter/, package:go_router/, etc. |
| TypeScript/JS | ./path, ../path | react, lodash, express, etc. |
| Python | from .module, from .. | from flask, import requests |
| Rust | use crate::, use super:: | use std::, external crates |The command auto-detects the project name from
pubspec.yaml, package.json, or pyproject.toml.$3
Export a template as a shareable
.brick file. Perfect for sharing templates with teammates or between machines.`bash
Export to current directory
brick export nestjs-authBy index
brick export 0Specify output path
brick export 0 --output ~/Desktop/my-auth.brick
`Options:
-
-o, --output ā Output file path (default: ./)Example output:
`
ā š§± Exporting template
ā ā Template: nestjs-auth
ā ā Files: 5 files
ā ā Output: /Users/you/nestjs-auth.brick
ā
ā ā Export complete!
ā Size: 12.34 KB
ā
ā Share this file and import with:
ā brick import nestjs-auth.brick
ā
`$3
Import a template from a
.brick file.`bash
Import from .brick file
brick import nestjs-auth.brickImport with custom name
brick import nestjs-auth.brick --name my-auth-v2Force overwrite existing template
brick import nestjs-auth.brick --force
`Options:
-
-n, --name ā Custom name for the imported template
- -f, --force ā Overwrite existing template without promptingExample output:
`
ā š§± Importing template
ā ā File: /Users/you/nestjs-auth.brick
ā ā Template: nestjs-auth
ā ā Description: JWT authentication module
ā ā Files: 5 files
ā
ā ā Import complete!
ā
ā View structure: brick tree nestjs-auth
ā Apply template: brick apply nestjs-auth
ā
`Smart Ignore System
Brick automatically ignores common dependency directories, build outputs, and generated files across all frameworks. This keeps your templates clean and portable.
$3
| Framework | Automatically Ignored |
| ------------- | ------------------------------------------------------------------- |
| Node.js |
node_modules/, .npm/, .yarn/, .pnpm-store/ |
| Python | __pycache__/, .venv/, venv/, .pytest_cache/, .mypy_cache/ |
| Flutter | .dart_tool/, .pub-cache/, build/, .flutter-plugins* |
| Rust | target/ |
| Go | vendor/ |
| Java | .gradle/, .idea/, out/, build/ |
| iOS | Pods/, .symlinks/, DerivedData/ |
| .NET | bin/, obj/, packages/ |
| Build | dist/, build/, .next/, .nuxt/, .output/, .vercel/ |
| Cache | .cache/, .temp/, .turbo/, coverage/ |
| VCS | .git/, .svn/, .hg/ |
| IDE | .idea/, .vscode/ (settings, not launch configs) |$3
| Category | Files |
| ------------ | ------------------------------------------------------------------ |
| Locks |
package-lock.json, yarn.lock, pnpm-lock.yaml, Podfile.lock |
| Env | .env, .env.local, .env.production, .env.* |
| OS | .DS_Store, Thumbs.db, desktop.ini |
| Logs | .log, npm-debug.log, yarn-debug.log* |
| Metadata | brick.json (template metadata) |This means when you save a template, you get only the source code ā no bloat:
`bash
Before smart ignore (hypothetical)
flutter-app: 1,247 files, 89.2 MB āWith smart ignore (actual)
flutter-app: 42 files, 156 KB ā
`Framework Agnostic
Brick works with any language or framework since it operates at the file level:
| Category | Examples |
| -------------- | ---------------------------------------------------- |
| Frontend | React, Vue, Angular, Svelte, Solid, Astro |
| Backend | NestJS, Express, FastAPI, Django, Rails, Spring Boot |
| Mobile | React Native, Flutter, Swift, Kotlin |
| Languages | TypeScript, JavaScript, Python, Go, Rust, Java, C# |
| Infrastructure | Terraform, Pulumi, Docker, Kubernetes configs |
| Other | Markdown docs, config files, shell scripts |
Storage Location
Templates are stored locally at:
`
~/.codebrick/
āāā config.json # Configuration
āāā store.json # Template registry
āāā templates/ # Actual template files
āāā nestjs-auth/
āāā react-modal/
āāā ...
`Examples
$3
`bash
From your existing project with a working auth implementation
cd ~/projects/my-backend
brick save nestjs-auth ./src/auth \
--description "JWT authentication with Passport" \
--tags nestjs,auth,jwt,passport \
--detect-deps
`$3
`bash
Create new project
nest new my-new-api
cd my-new-apiApply the auth template (by index or name)
brick apply 0 ./src/authInstall dependencies (brick will show you the command)
npm install @nestjs/jwt @nestjs/passport passport-jwt bcrypt
`$3
`bash
brick save react-modal ./src/components/Modal \
--description "Animated modal with backdrop" \
--tags react,modal,ui,animation
`$3
`bash
brick save flutter-clean ./lib \
--description "Clean architecture with BLoC" \
--tags flutter,bloc,clean-architecture
`$3
`bash
brick save docker-dev ./docker \
--description "Docker Compose development setup" \
--tags docker,devops
`$3
`bash
List templates
brick list
0 nestjs-auth
1 react-modal
2 flutter-clean
Use index for faster operations
brick tree 0
brick info 1
brick apply 2 ./lib
brick size 0
brick clean 2 # Remove local imports
brick delete 1 --force
`$3
`bash
Export a template to share
brick export nestjs-auth
Creates: nestjs-auth.brick (shareable file)
Send the .brick file to your teammate, then they run:
brick import nestjs-auth.brickOr import with a custom name
brick import nestjs-auth.brick --name company-auth
``Contributions are welcome! Please open an issue or submit a pull request.