Modular Project Setup Architecture
Complete guide to the new project setup system
The setup scripts have been refactored into a modular, extensible system following the patterns established in this workspace. This document explains how the pieces fit together and how to extend them.
Architecture Overview
setup-project.ps1 (Orchestrator)
↓
Setup.psm1 (Core Module)
↓
├── New-ProjectStructure()
├── New-Gitignore()
├── New-ReadmeFile()
├── New-ArchitectureFile()
├── New-ClaudeInstructions()
├── New-AgentsInstructions()
├── Initialize-ProjectGit()
├── Invoke-LanguageStarter() ← Delegates to language-specific scripts
├── Test-ProjectBuildable()
├── Test-ProjectTestable()
└── New-ProjectInitialCommit()
Utility functions exported by Setup.psm1
├── Write-Step()
├── Write-Success()
├── Write-WarningMessage()
├── Assert-CommandAvailable()
├── Test-CommandAvailable()
└── Invoke-NativeCommand()
Language Starters
├── setup-starter-node.ps1 (Generates package.json, tsconfig.json, etc.)
├── setup-starter-python.ps1 (Generates requirements.txt, setup.py, etc.)
├── setup-starter-csharp.ps1 (Extensible - create as needed)
├── setup-starter-rust.ps1 (Extensible - create as needed)
└── ... more languages ...
File Organization
setup-llm/
├── ai-cluster/ # Local AI cluster compose/config/scripts/tests
│ ├── compose.yaml # AI gateway + provider topology by profile
│ ├── config/ # LiteLLM routing and model-manifest templates
│ ├── scripts/ # Start/stop/test/measure workflow entry points
│ └── tests/ # Pester validation and contract placeholders
├── scripts/
│ ├── setup.ps1 # OS-detecting entry point
│ ├── setup-windows.ps1 # Winget prerequisites
│ ├── setup-macos.ps1 # Homebrew/npm prerequisites
│ ├── setup-ubuntu.ps1 # apt/pipx/npm prerequisites
│ ├── setup-workstation.ps1 # Shared integration orchestration
│ ├── setup-project.ps1 # Project generator entry point
│ ├── modules/
│ │ └── Setup.psm1 # Shared utility + project creation module
│ ├── workstation/ # Component installers
│ └── starters/ # Language-specific generators
├── docker/ # GitHub MCP Compose and secret files
├── config/ # Schema and example configuration
└── docs/ # Docusaurus-ready documentation
How It Works
Workstation Orchestration
setup.ps1 detects Windows, macOS, or Linux and delegates to its platform script. Each platform script installs missing prerequisites and invokes setup-workstation.ps1. The shared orchestrator runs the OS-independent component installers. MCP commands use cmd /c npx on Windows and invoke npx directly on macOS and Linux.
Project Orchestration (setup-project.ps1)
The main script:
- Imports
Setup.psm1 - Uses exported utility and core project functions
- Validates input parameters
- Gets Git configuration
- Calls module functions in sequence
- Handles errors and reports progress
Key features:
- Uses
[CmdletBinding(SupportsShouldProcess)]for-WhatIfsupport - Follows existing script patterns (parameter validation, error handling)
- Uses shared utility functions exported by
Setup.psm1for consistent output - Supports multiple switch options:
-SkipGit,-SkipValidation,-AutoCommit
Phase 2: Core Functions (Setup.psm1)
The module contains focused functions, each doing one thing well:
Structure functions:
New-ProjectStructure()— Creates directory treeNew-ProjectFile()— Creates a file with content
File generators:
New-Gitignore()— Language-specific .gitignoreNew-EnvExample()— .env.example templateNew-ReadmeFile()— README.md with language commandsNew-ArchitectureFile()— docs/architecture.md templateNew-AdtTemplate()— ADR templateNew-ClaudeInstructions()— CLAUDE.md generatorNew-AgentsInstructions()— AGENTS.md generator
Git functions:
Initialize-ProjectGit()— git init + config
Language support:
Invoke-LanguageStarter()— Delegates to language-specific scripts
Validation functions:
Test-ProjectBuildable()— Runs build commandTest-ProjectTestable()— Runs test command
Commit functions:
New-ProjectInitialCommit()— Creates initial commit
Key patterns:
- Each function has
[Parameter()]attributes with validation - Functions use relative paths (ProjectPath as base)
- Error handling via
-ErrorAction - Progress reporting via
Write-Success()andWrite-WarningMessage()
Phase 3: Language Customization (setup-starter-*.ps1)
Language-specific scripts generate starter files:
Node.js example:
.\scripts\starters\setup-starter-node.ps1 -ProjectPath 'D:\Projects\MyApp' -ProjectName 'MyApp'
Generates:
package.jsontsconfig.json.eslintrc.jsonjest.config.js.prettierrc.jsonsrc/index.jstests/index.test.js
Creating a new starter:
- Copy
setup-starter-node.ps1template - Replace language-specific content
- Name it
setup-starter-<language>.ps1 - Test by running
setup-project.ps1 -Language '<language>'
Usage Examples
Basic Project Creation
cd D:\Projects\SubZeroDev.Workspace\setup-llm
.\scripts\setup-project.ps1 `
-ProjectPath 'D:\Dropbox\Projects\MyApp' `
-ProjectName 'MyApp' `
-Language 'node'
Result:
- Directory structure created
- Common files generated (README, CLAUDE.md, AGENTS.md, docs/)
- Node.js starters created (package.json, tsconfig.json, etc.)
- Git initialized
- User is guided to next steps
With Auto-Commit
.\scripts\setup-project.ps1 `
-ProjectPath 'D:\Dropbox\Projects\MyBackend' `
-ProjectName 'Backend' `
-Language 'csharp' `
-AutoCommit
Result:
- Same as above, PLUS
- Build and tests validated
- Initial commit automatically created
Skipping Steps
.\scripts\setup-project.ps1 `
-ProjectPath 'D:\Dropbox\Projects\ExistingProject' `
-ProjectName 'ExistingProject' `
-Language 'python' `
-SkipGit `
-SkipLanguageStarter `
-SkipValidation
Result:
- Only creates common files and client instructions
- No Git operations, language starters, or validation
Test (WhatIf Mode)
.\scripts\setup-project.ps1 `
-ProjectPath 'D:\Dropbox\Projects\TestProject' `
-ProjectName 'TestProject' `
-Language 'node' `
-WhatIf
Result:
- Shows what would be done without making changes
Extending the System
Add Support for a New Language
-
Create the starter script
Copy-Item scripts\starters\setup-starter-node.ps1 scripts\starters\setup-starter-rust.ps1 -
Edit for Rust
- Replace Node-specific files with Rust files
- Update
Cargo.tomlinstead ofpackage.json - Create
src/main.rsinstead ofsrc/index.js - Keep the script structure and comment style
-
Update language commands in
setup-project.ps1rust = @{
install = 'cargo fetch'
build = 'cargo build --release'
test = 'cargo test'
lint = 'cargo clippy'
run = 'cargo run --release'
} -
Test
.\scripts\setup-project.ps1 -ProjectPath 'D:\Test\Rust' -ProjectName 'RustApp' -Language 'rust' -
Document in Language starters
Add a New Generation Function to ProjectSetup Module
-
Open Setup.psm1
-
Add your function
function New-CustomFile {
param(
[Parameter(Mandatory)][string]$ProjectPath,
[Parameter(Mandatory)][string]$CustomParam
)
$content = @"
Your file content
"@
New-ProjectFile -ProjectPath $ProjectPath -RelativePath 'custom.txt' -Content $content
} -
Export it in the
Export-ModuleMemberlist -
Call it from
setup-project.ps1New-CustomFile -ProjectPath $ProjectPath -CustomParam 'value'
Add a New Validation Check
- Add the function to Setup.psm1
- Call it in setup-project.ps1 before/after build/test validation
- Report results using
Write-Success()orWrite-WarningMessage()
Compatibility with Existing Scripts
The new system maintains compatibility with existing scripts:
- Setup.psm1 — Shared utility and project functions used by all scripts
- install-*.ps1 — Workstation setup scripts still work
- setup.ps1 — Detects the host OS and delegates Phase 1 to a platform entry point
You can now use setup-project.ps1 for Phase 2 and Phase 3 project creation.
Troubleshooting
Module Import Fails
Error: Setup module not found
Solution:
# Ensure you're in the setup directory
cd D:\Projects\SubZeroDev.Workspace\setup-llm
# Check file exists
Test-Path .\scripts\modules\Setup.psm1
# Try again
.\scripts\setup-project.ps1 ...
Language Starter Not Found
Warning: Language starter script not found
Solution:
- Create
setup-starter-<language>.ps1using the template - Or skip with
-SkipLanguageStarter - See Language starters for details
Git Config Not Found
Error: Cannot determine Git user.name
Solution:
# Set Git config
git config --global user.name 'Your Name'
git config --global user.email '[email protected]'
# Or provide explicitly
.\scripts\setup-project.ps1 ... -GitUserName 'Your Name' -GitUserEmail '[email protected]'
Build/Test Validation Fails
Warning: Build validation skipped or failed
Likely cause: Language tools not installed yet
Solution:
# Install dependencies first
npm install # for Node
pip install -r requirements.txt # for Python
# Then run with validation
.\scripts\setup-project.ps1 ... -AutoCommit
# Or skip validation for now
.\scripts\setup-project.ps1 ... -SkipValidation
Performance
The system is designed to be fast:
- Minimal external command calls
- Lazy evaluation of language commands
- Optional validation and commit steps
- Parallel-capable directory creation
Typical creation time: 1-3 seconds (without validation) With validation: 5-15 seconds (depends on language tooling)
References
- Setup specification — Requirements and workflows
- Setup flowcharts — Visual process diagrams
- Language starters — Creating language-specific setup
scripts/modules/Setup.psm1— Shared utilities and core module documentationsetup-project.ps1— Script with inline documentation