Skip to content

DevShedLabs/new

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

new

Version License Go

A fast, single-binary CLI for scaffolding files and projects.

new index.html
new my-app --template react

Installation

go install github.com/DevShedLabs/new@latest

Or build from source:

git clone https://github.com/DevShedLabs/new
cd new
go build -o new .

Usage

Create a file

Detects the file type by extension and generates smart boilerplate automatically.

new index.html       # HTML5 skeleton
new main.go          # Go package main
new styles.css       # CSS reset + box-sizing
new app.ts           # TypeScript module stub
new script.sh        # Bash shebang + set -euo pipefail
new data.json        # Empty JSON object
new notes.md         # Markdown heading
new index.php        # Empty file (no built-in template)

Any extension without a built-in template creates an empty file.

Create a directory

A trailing slash or a name with no extension creates a directory (mkdir -p).

new assets/css/           # creates assets/css/
new src/components/       # creates src/components/
new src/components/Button # no extension — creates a directory

Scaffold a project

Use --template (or -t) to scaffold a full project from a built-in template or user blueprint.

new my-site --template html
new my-app --template react
new my-app --template my-blueprint   # user blueprint from ~/.new/blueprints/

The project is created as a subdirectory of the current working directory.

List available templates and blueprints

new list

Shows all built-in templates and any user blueprints in ~/.new/blueprints/, with descriptions.

Capture a project as a blueprint

new blueprint capture <name>          # capture current directory
new blueprint capture <name> <path>   # capture a specific directory

Snapshots a project into ~/.new/blueprints/<name>/ so it can be reused as a template. Build artifacts (node_modules, .git, vendor, dist, build, .next, __pycache__, .venv) are excluded automatically. A blueprint.yaml manifest is generated if one doesn't exist.

Check the installed version

new --version

Update to the latest version

new update

Installs the latest tagged release directly from GitHub, bypassing any local cache.

Shell completion

Completion scripts are generated by new completion <shell>. Follow the steps for your shell:

Zsh (macOS with Homebrew)

new completion zsh > /opt/homebrew/share/zsh/site-functions/_new

Start a new shell session to activate.

Zsh (Linux)

new completion zsh > ~/.zsh/completions/_new
# Add to ~/.zshrc if not already present:
# fpath=(~/.zsh/completions $fpath)
# autoload -Uz compinit && compinit

Bash (macOS with Homebrew)

new completion bash > /opt/homebrew/etc/bash_completion.d/new

Bash (Linux)

new completion bash > /etc/bash_completion.d/new

Fish

new completion fish > ~/.config/fish/completions/new.fish

PowerShell

new completion powershell >> $PROFILE

Flags

Flag Short Description
--template -t Template or blueprint name
--output -o Output directory (default: current directory)
--var key=value -v Pass variables to the template (repeatable)

Example with variables:

new my-app --template react --var Author="Jeffrey"

Built-in Templates

Template Description
html HTML5 project with index.html, css/main.css, js/main.js
react Vite + React + TypeScript starter

Blueprints

Blueprints are user-defined templates that live in ~/.new/blueprints/. Any blueprint directory placed there is immediately available as a --template value.

Blueprint resolution order:

  1. ~/.new/blueprints/<name>/ — user blueprints take precedence
  2. Built-in embedded templates

This means you can override any built-in template by creating a blueprint with the same name.

Creating a blueprint manually

A blueprint is just a folder of files. Template variables are rendered using Go's text/template syntax — {{.Name}}, {{.Author}}, etc.

~/.new/blueprints/
└── my-blueprint/
    ├── blueprint.yaml       # optional manifest
    ├── index.html
    └── src/
        └── main.js

Variable names in file paths are also rendered:

src/{{.Name}}.go   →   src/my-app.go

blueprint.yaml

The manifest is optional but recommended. It documents the blueprint and declares expected variables.

name: my-blueprint
description: My custom project starter.
vars:
  - Name
  - Author
defaults:
  Author: "Your Name"

Available variables

Variable Value
{{.Name}} The project name passed as the first argument
{{.Template}} The template/blueprint name
Any --var flag --var Foo=bar{{.Foo}}
Blueprint defaults Defined in blueprint.yaml under defaults

Roadmap

  • Icon and favicon generation
  • Variable prompting for blueprints that declare vars
  • Remote blueprint fetching

License

MIT

About

A fast, single-binary CLI for scaffolding files and projects.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors