Skip to main content

A lightweight DSL for scaffolding files and folders

Project description

🧱 Bytecraft

A human-readable DSL for scaffolding files and folders.

pip install bytecraft

Bytecraft lets you describe a project structure in plain, readable instructions and execute it with a single command — no Bash, no Python boilerplate, no mental overhead.

# bootstrap.bc

set project "my-app"
set version "1.0.0"

set-working-folder "{{project}}"

make-folder "src"
make-folder "src/utils"
make-folder "assets"

make-file "README.md" with "# {{project}}"
make-file "src/main.py" with "print('Hello, World!')"
make-file "src/utils/helper.py"
py -m bytecraft bootstrap.bc
[Bytecraft] Working folder set: my-app
[Bytecraft] Created folder: my-app/src
[Bytecraft] Created folder: my-app/src/utils
[Bytecraft] Created folder: my-app/assets
[Bytecraft] Created file: my-app/README.md
[Bytecraft] Created file: my-app/src/main.py
[Bytecraft] Created file: my-app/src/utils/helper.py

Installation

Requires Python 3.10+

pip install bytecraft

Commands

set-working-folder

Sets the base directory for all subsequent relative paths. Created automatically if it doesn't exist.

set-working-folder "my-project"

make-folder

Creates a directory and any missing parent directories. Does nothing if the folder already exists.

make-folder "src/utils"

make-file

Creates a file. Parent directories are created automatically. Overwrites if the file already exists.

# Empty file
make-file "src/__init__.py"

# Inline content
make-file "VERSION" with "1.0.0"

# Multi-line content block
make-file "README.md" with ---
# My Project

Some description here.
---

copy-file

Copies a file or folder to a new location. Parent directories are created automatically. If copying a folder that already exists at the destination, it is replaced.

# Copy a file
copy-file "src/app.py" to "backup/app.py"

# Copy an entire folder
copy-file "src" to "src_backup"

move-file

Moves a file or folder to a new location. Parent directories are created automatically.

move-file "build/output.js" to "dist/app.js"
move-file "temp" to "archive/temp"

make-zip

Creates a zip archive from a file or folder. Folder structure is preserved inside the zip.

# Zip a folder
make-zip "releases/v1.0.zip" from "dist"

# Zip a single file
make-zip "releases/app.zip" from "dist/app.py"

set

Defines a variable. Variables are referenced anywhere using {{name}} syntax — in paths, content, and template calls.

set project "my-app"
set version "1.0.0"

make-file "VERSION" with "{{version}}"
make-file "src/main.py" with "# {{project}} v{{version}}"

Variables interpolate inside multi-line blocks too:

set author "Sourasish Das"

make-file "README.md" with ---
# {{project}}

Maintained by {{author}}.
---

define-template / use-template

Templates let you define reusable scaffolding blocks and stamp them out with different values.

define-template "module"
  make-folder "src/{{name}}"
  make-file "src/{{name}}/__init__.py"
  make-file "src/{{name}}/main.py" with "# {{name}} module"
end-template

use-template "module" name "auth"
use-template "module" name "api"
use-template "module" name "db"

Variables passed to use-template are local to that call — they don't leak back into the outer script. Global variables defined with set are still accessible inside the template body.


include

Runs another .bc file inline, with fully shared state. Variables, templates, the working folder, and strict mode all carry across in both directions.

include "base.bc"
include "templates/python.bc"

Paths are resolved relative to the calling script's directory, not the working folder.


strict on / strict off

Enables or disables strict mode. In strict mode, warnings become fatal errors — undefined variables, unknown commands, and missing source files all halt execution immediately.

strict on

set version "1.0.0"
make-file "VERSION" with "{{version}}"   # fine
make-file "bad.txt" with "{{typo}}"      # ERROR: halts execution

strict off

Strict mode can be toggled on and off within the same script.


Comments

Lines starting with # are ignored.

# This is a comment

Forgiving Syntax

Bytecraft is intentionally forgiving. Quotes are optional — if they're missing, Bytecraft will recover and interpret your intent:

make-file hello.txt with Hello World

is treated the same as:

make-file "hello.txt" with "Hello World"

Unknown commands print a warning and are skipped rather than crashing the whole script. Enable strict on if you want the opposite behaviour.


Full Example

# Full project scaffold + release build

strict on

set project "dashboard"
set author "Sourasish Das"
set version "1.0.0"

set-working-folder "{{project}}"

# Pull in shared folder templates
include "common/folders.bc"

# Stamp out feature modules
define-template "module"
  make-folder "src/{{name}}"
  make-file "src/{{name}}/__init__.py"
  make-file "src/{{name}}/main.py" with "# {{name}} — part of {{project}}"
end-template

use-template "module" name "auth"
use-template "module" name "api"
use-template "module" name "db"

# Static files
make-file "VERSION" with "{{version}}"

make-file "README.md" with ---
# {{project}}

Version: {{version}}
Author: {{author}}
---

make-file "tests/test_main.py" with ---
import unittest

class TestMain(unittest.TestCase):
    def test_placeholder(self):
        self.assertTrue(True)
---

# Package for release
copy-file "src" to "dist/src"
make-zip "releases/{{project}}-{{version}}.zip" from "dist"

Limitations (v0.2.0)

  • No loops or conditionals
  • No append mode
  • No import of variables from external files (e.g. .env)

These are planned for future versions.


Roadmap

  • Variables and interpolation
  • Multi-line file content blocks
  • copy-file and move-file
  • make-zip
  • Templates (define-template / use-template)
  • include
  • Strict mode
  • append-file command
  • Loops and conditionals
  • .env / external variable files

License

Server-Lab Open-Control License (SOCL) 1.0
Copyright (c) 2025 Sourasish Das

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bytecraft-0.2.0.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bytecraft-0.2.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file bytecraft-0.2.0.tar.gz.

File metadata

  • Download URL: bytecraft-0.2.0.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for bytecraft-0.2.0.tar.gz
Algorithm Hash digest
SHA256 bc9e17f11b40a7baa74bd0b02965da85358cd49f1a53370c6ffab58ce5fc1355
MD5 7b9e768c82e632df5c71168bccbe5ebb
BLAKE2b-256 62573888d50c242118990867507df7b78f272c2e550f0530703247e072c83089

See more details on using hashes here.

File details

Details for the file bytecraft-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: bytecraft-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for bytecraft-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee1be98559d0322c7220a55f685cd846d283a2a48e68e9c97d9a3143b4a446dd
MD5 a69d563bcec4d952c699c7278b8056ba
BLAKE2b-256 ee5603d56ee28a5038e7f39691068f2a24881588439ed12cf278bedaf57640ba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page