Glimx Workspace Templates
Glimx CLI provides pre-configured project templates to help you quickly start new projects with best practices and sensible defaults. This document explains how to use and customize these templates.
Available Templates
Glimx comes with three built-in templates:
- node-typescript - Modern Node.js project with TypeScript, ESLint, and Prettier
- react-vite - React application with Vite, TypeScript, and TailwindCSS
- python-fastapi - Python FastAPI project with Poetry package manager
Using Templates
To create a new project from a template, use the --template flag:
# Create a new Node.js TypeScript project
glimx --template node-typescript my-project
# Create a new React + Vite project
glimx --template react-vite my-app
# Create a new Python FastAPI project
glimx --template python-fastapi my-api
This will:
- Create a new directory with the specified name
- Generate all files from the template
- Initialize a git repository
- Install dependencies (if applicable)
Template Details
Node.js + TypeScript Template
This template creates a modern Node.js project with:
- TypeScript for type safety
- ESLint for code quality
- Prettier for code formatting
- Jest for testing
- VS Code configuration
File structure:
my-project/
├── src/
│ ├── index.ts
│ └── __tests__/
├── package.json
├── tsconfig.json
├── eslint.config.js
├── prettier.config.js
├── jest.config.js
└── .gitignore
React + Vite Template
This template creates a React application with:
- Vite for fast development
- TypeScript for type safety
- TailwindCSS for styling
- React Router for navigation
- ESLint and Prettier for code quality
- Vitest for testing
File structure:
my-app/
├── src/
│ ├── App.tsx
│ ├── main.tsx
│ ├── components/
│ └── __tests__/
├── public/
├── index.html
├── package.json
├── tsconfig.json
├── vite.config.ts
├── tailwind.config.js
├── postcss.config.js
├── eslint.config.js
└── .gitignore
Python FastAPI Template
This template creates a Python FastAPI project with:
- FastAPI for building APIs
- Poetry for dependency management
- Pydantic for data validation
- Uvicorn for development server
- Pytest for testing
File structure:
my-api/
├── src/
│ ├── main.py
│ ├── api/
│ └── tests/
├── pyproject.toml
├── poetry.lock
├── README.md
└── .gitignore
Customizing Templates
Modifying Template Files
You can customize the template files by editing the JSON template files located in packages/opencode/templates/:
node-typescript.json- Node.js + TypeScript templatereact-vite.json- React + Vite templatepython-fastapi.json- Python FastAPI template
Each template file contains:
- File definitions with content
- Package dependencies
- Scripts to run after creation
Creating New Templates
To create a new template:
- Create a new JSON file in the templates directory
- Define the template structure following the existing format
- Add an entry to
index.json
Example template structure:
{
"name": "My Custom Template",
"description": "A custom project template",
"files": {
"src/index.ts": {
"content": "console.log('Hello, World!');"
},
"package.json": {
"content": "{\n \"name\": \"{{projectName}}\",\n \"version\": \"1.0.0\"\n}"
}
},
"dependencies": {
"dev": ["typescript", "@types/node"],
"prod": ["express"]
},
"scripts": [
"npm install",
"git init",
"git add .",
"git commit -m \"Initial commit\""
]
}
Template Variables
Templates support variables that are replaced during project creation:
{{projectName}}- The name of the project{{username}}- The current user's username{{date}}- Current date in YYYY-MM-DD format
Example usage in template:
{
"files": {
"README.md": {
"content": "# {{projectName}}\n\nCreated by {{username}} on {{date}}"
}
}
}
Advanced Template Features
Conditional Files
You can include files conditionally based on user input:
{
"files": {
"src/components/Button.tsx": {
"content": "...",
"condition": "includeUI"
}
},
"prompts": [
{
"name": "includeUI",
"type": "confirm",
"message": "Include UI components?",
"default": true
}
]
}
Post-Creation Scripts
Run scripts after the project is created:
{
"scripts": [
"npm install",
"git init",
"git add .",
"git commit -m \"Initial commit\""
]
}
Best Practices
When Creating Templates
- Keep it simple - Templates should provide a minimal starting point
- Use popular tools - Choose widely-adopted tools and frameworks
- Include documentation - Add README files explaining the project structure
- Configure linting - Include ESLint/Prettier or equivalent for code quality
- Set up testing - Include a basic testing setup
- Version control - Initialize git repository with appropriate .gitignore
When Using Templates
- Review the files - Examine the generated files before starting development
- Update dependencies - Check for newer versions of dependencies
- Customize configuration - Adjust configurations to match your needs
- Add project-specific files - Add any additional files specific to your project
Troubleshooting Templates
Template Not Found
If you get an error that a template is not found:
- Check that the template name is correct
- Verify the template exists in
packages/opencode/templates/ - Ensure
index.jsonincludes the template
Dependency Installation Failures
If dependencies fail to install:
- Check your internet connection
- Verify you have the required package managers installed (npm, yarn, poetry, etc.)
- Try installing dependencies manually:
cd my-project
npm install # or poetry install for Python projects
File Generation Issues
If files are not generated correctly:
- Check the template JSON file for syntax errors
- Verify all required fields are present
- Ensure file paths are correct
Contributing Templates
To contribute a new template to Glimx:
- Fork the Glimx repository
- Create your template following the existing format
- Add it to
index.json - Test the template thoroughly
- Submit a pull request with documentation
Next Steps
After creating a project from a template:
- Review the generated files and README
- Install dependencies if not automatically installed
- Start the development server
- Begin customizing the project for your needs
For more information on using Glimx CLI: