Use this template β’ View Demo β’ Report Bug
- π Modern C23 - Latest C standard with Aro compiler
- β‘ Zig Build System - Fast, reliable builds with cross-compilation
- ποΈ Well-Structured - Organized project layout ready for growth
- π§ͺ Testing Included - Test framework with examples
- π¨ Smart CLI - Colored output, help text, argument parsing
- πΌοΈ TUI Support - NCurses integration for interactive terminal UIs
- π§ Configuration - Layered config system (file β env β args)
- π¦ Minimal Dependencies - Only Zig, libc, and ncurses
- π€ CI/CD Ready - GitHub Actions workflow included
- π Conditional Runners - Uses self-hosted runners for template repo, GitHub-hosted for derived repos
- β‘ Caching - Speeds up builds by caching Zig dependencies and build artifacts
- π Release Gating - Ensures releases only happen on tags in main branch
- π‘οΈ Security Scanning - CodeQL integration for vulnerability detection
- π¦ Artifact Management - Unique artifact naming to avoid collisions
- π·οΈ Version Pinning - Pinned GitHub Actions versions for reproducibility
- π« Concurrency Control - Cancels redundant CI runs on same branch
- π Dynamic Binary Naming - Extracts binary name from build.zig.zon
- π§Ή Template Cleanup - Automated cleanup of template-specific files and placeholders
- π OpenCLI Compliant - Standardized CLI behavior
- π Dependency Updates - Automated updates with Dependabot/Renovate
- π Pre-commit Hooks - Code quality enforcement before commits
- π³ Devcontainer Support - Consistent development environments
- π Comprehensive Documentation - Detailed guides and examples
- Click "Use this template"
- Name your repository
- Click "Create repository"
gh repo create my-cli \
--template sammyjoyce/c23-cli-template \
--public \
--clone
# Clone your new repo
git clone https://github.com/YOU/YOUR-REPO
cd YOUR-REPO
# Build (with TUI support)
zig build -Doptimize=ReleaseSafe
# Build without TUI (if ncurses is not available)
zig build -Doptimize=ReleaseSafe -Denable-tui=false
# Run
./zig-out/bin/YOUR-REPO --help
your-cli/
βββ src/
β βββ main.c # Entry point
β βββ core/ # Core functionality
β β βββ config.c/h # Configuration
β β βββ error.c/h # Error handling
β β βββ types.h # Type definitions
β βββ cli/ # CLI interface
β β βββ args.c/h # Argument parsing
β β βββ help.c/h # Help text
β βββ io/ # Input/Output
β βββ utils/ # Utilities
βββ test/ # Test suite
βββ build.zig # Build config
βββ opencli.json # CLI specification
The template includes working examples:
# Greeting command
$ myapp hello
Hello, World!
$ myapp hello Alice
Hello, Alice!
# Echo command
$ myapp echo Hello from CLI
Hello from CLI
# Info command
$ myapp info
Application: myapp
Version: 1.0.0
Build: Jul 27 2025 13:16:11
# Interactive TUI menu
$ myapp menu
# Opens an ncurses-based interactive menu
The template automatically:
- β
Replaces
myapp
with your project name - β Updates all references and metadata
- β Preserves template structure
- β Removes template-specific files
- β Commits the changes
Check the Actions tab to see progress.
Edit src/main.c
:
if (strcmp(command, "deploy") == 0) {
printf("Deploying application...\n");
// Your deployment logic
return APP_SUCCESS;
}
Edit src/cli/help.c
to describe your commands.
- Create your
.c
file insrc/
- Add to
build.zig
:
const c_sources = [_][]const u8{
// ... existing files ...
"src/features/deploy.c", // Your new file
};
- Zig (master branch) - Install via zvm
- C compiler - For system libraries
- NCurses - For TUI support
- Ubuntu/Debian:
sudo apt-get install libncurses-dev
- macOS:
brew install ncurses
- Fedora:
sudo dnf install ncurses-devel
- Ubuntu/Debian:
This template provides several tools to enhance your development experience:
- Devcontainer Support - Pre-configured development environment with all dependencies
- VS Code Settings - Opinionated settings for C/Zig development
- Pre-commit Hooks - Automated code quality checks before commits
- Tasks Configuration - Predefined build and test tasks for VS Code
- Debug Configuration - Ready-to-use debugging setup for VS Code
# Build
zig build # Debug build
zig build -Doptimize=ReleaseSafe # Release build
# Test
zig build test # Run all tests
# Clean
zig build clean # Remove build artifacts
# Format
zig fmt build.zig # Format build file
Your app supports config from multiple sources:
- CLI arguments (highest priority)
- Environment variables
- Config file (
~/.config/yourapp/config.json
) - Defaults
- π Using This Template - Detailed setup guide
- π Quick Start Guide - Get up and running quickly
- π§ Installation - Platform-specific instructions
- ποΈ Architecture Overview - System design and module structure
- β‘ Zig Primer for C Developers - Understanding the build system
- π€ Contributing Guide - How to contribute to the project
- π§ͺ Advanced Usage Examples - Piping, scripting, and integration
- π Adding Commands - Extend the CLI
- π¨ Custom TUI Components - Build interactive interfaces
- βοΈ Configuration Guide - Config file examples
- π¬ Demo Gallery - Animated demonstrations
- π‘οΈ Security Policy - Reporting vulnerabilities
- π Code of Conduct - Community guidelines
- π Changelog - Version history
- π License - MIT License
- C23 - Latest features:
typeof
,_BitInt
, better type safety - Zig Build - Superior to Make/CMake, built-in cross-compilation
- Aro Compiler - Better C23 support than most system compilers
- Minimal Dependencies - Just Zig and libc, no complex toolchains
For problems with the template itself:
- Check existing issues
- Create a new issue
- Read template support
For issues with your generated project:
- Use your own repository's issues
- Check Zig documentation
- See C23 reference
Using this template? Add your project!
- Example CLI - Description
- Your project here!
This template is MIT licensed. See LICENSE for details.
When you use this template, you can choose any license for your project.
Ready to build your CLI app?
Made with β€οΈ by the open source community