A Terraform-inspired YAML-based directory scaffolding tool with state management.
Define your project structure in YAML, and Yark safely creates and updates it β never touching files it doesn't own.
- π YAML-defined structures - Clean, readable project definitions
- π‘οΈ State management - Terraform-style tracking of managed resources
- π Safe updates - Never deletes your manual files
- π¨ Colored diff output - See what will be created/deleted with visual highlights
- ποΈ Dry-run mode - Preview changes before applying
- π² Tree visualization - Beautiful terminal output with Rich
- π Idempotent - Run multiple times safely
pip install yark-scaffold1. Define your structure in YAML:
# project-structure.yaml
project/:
- src/:
- main.py
- utils.py
- tests/:
- test_main.py
- docs/:
- README.md
- config.yaml2. Create the structure:
yark create -f project-structure.yaml -p ./my-projectOutput:
β Structure created successfully in './my-project'
β State file created: .yark.state (tracks 7 resources)
3. Add your own files (safely):
cd my-project
touch .env # Your file
touch local_notes.txt # Your fileYark will never touch these files! β
4. Update the structure:
Modify your YAML, then:
yark update -f project-structure.yaml -p ./my-project --dry-runSee colored preview:
π my-project/
βββ π .env (unchanged)
βββ π local_notes.txt (unchanged)
βββ π new_file.py (new) β Green
βββ π old_file.py (deleted) β Red
βββ π src/
βββ ...
Creates directories and files from YAML.
yark create -f <yaml-file> -p <target-path> [--dry-run]Examples:
# Create in current directory
yark create -f structure.yaml
# Create in specific directory
yark create -f structure.yaml -p ./new-project
# Preview without creating
yark create -f structure.yaml -p ./new-project --dry-runWhat it does:
- Creates all files and folders from YAML
- Generates
.yark.statefile to track what it created
Updates existing structure to match YAML (only touches managed files).
yark update -f <yaml-file> -p <target-path> [--dry-run]Examples:
# Update structure
yark update -f structure.yaml -p ./my-project
# Preview changes
yark update -f structure.yaml -p ./my-project --dry-runWhat it does:
- Creates new files/folders from YAML
- Deletes files/folders that were removed from YAML (only if managed)
- Ignores files not in state (your manual files are safe!)
- Updates
.yark.state
Displays current directory structure.
yark list -p <directory>Examples:
# List current directory
yark list
# List specific directory
yark list -p ./my-projectYark uses a Terraform-style state file (.yark.state) to track which files it manages.
Initial create:
yark create -f structure.yaml -p ./project
# Creates: .yark.state tracking all created filesYou add your own files:
touch ./project/.env
touch ./project/notes.txt
# These are NOT in .yark.stateUpdate with modified YAML:
yark update -f structure.yaml -p ./project
# Only modifies files in .yark.state
# Your .env and notes.txt are IGNORED ββ
Only deletes managed files (those in .yark.state)
β
Ignores your manual files completely
β
Won't run update without state (prevents accidents)
β
Clear error messages if state is missing
root/:
- file1.txt
- file2.py
- subfolder/:
- nested_file.txt- Folders end with
/(required) - Files are strings in folder lists
- Nested folders use dict or list format
- Empty folders use empty list:
folder/: []
Simple project:
project/:
- README.md
- main.py
- config.jsonNested structure:
webapp/:
- frontend/:
- src/:
- App.jsx
- index.js
- public/:
- index.html
- backend/:
- api/:
- routes.py
- main.py
- docker-compose.ymlMixed format:
project/:
src/: # Dict style
- main.py
- utils.py
tests/: # List style
- test_main.py
- README.md # Root files- Bootstrap new projects with consistent structure
- Team project templates everyone uses same layout
- Monorepo management maintain folder structure across repos
- Documentation YAML serves as structure documentation
- CI/CD automate project setup in pipelines
git clone https://github.com/youssef-abbih/yark.git
cd yark
pip install -e .
pip install -r requirements.txtpytest tests/ -v
# With coverage
pytest tests/ --cov=yark --cov-report=term-missingyark/
βββ yark/ # Source code
β βββ cli.py # Command-line interface
β βββ parser.py # YAML parsing
β βββ builder.py # Structure creation
β βββ updater.py # Structure updates
β βββ scanner.py # Directory scanning
β βββ state.py # State management
β βββ ...
βββ tests/ # Test suite
β βββ fixtures/ # Test YAML files
β βββ test_*.py
βββ README.md
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new features
- Ensure tests pass:
pytest - Submit a pull request
MIT License - see LICENSE file for details.
- Rich - Beautiful terminal output
- Inspired by Terraform's state management approach
- YAML for clean, readable configuration
- File content templating
- Interactive YAML generator (
yark init) -
.yarkignoresupport - Remote state backends
- Project templates library
Start structuring your projects with Yark β safe, simple, and state-managed! π