init

Initialize Calor development environment with MSBuild integration and optional AI agent support.

Bash
calor init [options]

Overview

The init command sets up your project for Calor development by:

  1. Adding MSBuild targets - Integrates Calor compilation into your .NET build process
  2. Configuring AI agent integration (optional) - Creates skills/prompts for your preferred AI coding assistant

After running init, you can write .calr files alongside your .cs files and they'll compile automatically during dotnet build.


Quick Start

Bash
# Basic initialization (MSBuild integration only)
calor init

# Initialize with Claude Code support
calor init --ai claude

# Initialize with a specific .csproj
calor init --project MyApp.csproj

Options

OptionShortRequiredDescription
--ai-aNoAI agent to configure: claude, codex, gemini, github
--project-pNoTarget .csproj file (auto-detects if single .csproj exists)
--force-fNoOverwrite existing files without prompting

AI Agent Support (Optional)

When you specify --ai, the command also sets up AI-specific configuration files.

Claude (--ai claude)

Creates the following files:

FilePurpose
.claude/skills/calor/SKILL.mdCalor code writing skill with YAML frontmatter
.claude/skills/calor-convert/SKILL.mdC# to Calor conversion skill
.claude/settings.jsonHook configuration - enforces Calor-first development
CLAUDE.mdProject guidelines instructing Claude to prefer Calor for new code

Calor-First Enforcement

The .claude/settings.json file configures a PreToolUse hook that blocks Claude from creating .cs files. When Claude tries to write a C# file, it will see:

Plain Text
BLOCKED: Cannot create C# file 'MyClass.cs'

This is an Calor-first project. Create an .calr file instead:
  MyClass.calr

Use /calor skill for Calor syntax help.

Claude will then automatically retry with an .calr file. This enforcement ensures all new code is written in Calor.

Allowed file types:

  • .calr files (always allowed)
  • .g.cs generated files (build output)
  • Files in obj/ directory (build artifacts)

After initialization, use these Claude Code commands:

CommandDescription
/calorWrite new Calor code with Claude's assistance
/calor-convertConvert existing C# code to Calor syntax

Codex (--ai codex)

Creates the following files:

FilePurpose
.codex/skills/calor/SKILL.mdCalor code writing skill with YAML frontmatter
.codex/skills/calor-convert/SKILL.mdC# to Calor conversion skill
.codex/config.tomlMCP server configuration for Calor tools
AGENTS.mdProject documentation with Calor-first guidelines

MCP Server Integration

The .codex/config.toml file configures an MCP server that gives Codex direct access to Calor compiler tools (calor_typecheck, calor_verify_contracts, calor_analyze, calor_convert, and more):

toml
# BEGIN CalorC MCP SECTION - DO NOT EDIT
[mcp_servers.calor]
command = "calor"
args = ["mcp", "--stdio"]
# END CalorC MCP SECTION

See calor mcp for the complete list of available tools.

Enforcement

Codex CLI does not support hooks like Claude Code. MCP tools provide direct access to Calor compiler features, and Calor-first development is guidance-based, relying on AGENTS.md and the skill files.

This means:

  • Codex should create .calr files based on the instructions
  • MCP tools give Codex native access to compile, verify, and convert
  • Hooks are not supported, so enforcement is not automatic
  • Use calor analyze to find any unconverted .cs files

After initialization, use these Codex commands:

CommandDescription
$calorWrite new Calor code with Codex's assistance
$calor-convertConvert existing C# code to Calor syntax

Gemini (--ai gemini)

Creates the following files:

FilePurpose
.gemini/skills/calor/SKILL.mdCalor code writing skill with YAML frontmatter
.gemini/skills/calor-convert/SKILL.mdC# to Calor conversion skill
.gemini/settings.jsonHook configuration - enforces Calor-first development
GEMINI.mdProject guidelines instructing Gemini to prefer Calor for new code

Calor-First Enforcement

Like Claude Code, Gemini CLI supports hooks (as of v0.26.0+). The .gemini/settings.json file configures a BeforeTool hook that blocks Gemini from creating .cs files.

Gemini will receive a JSON response blocking the operation and suggesting an .calr file instead. This enforcement ensures all new code is written in Calor.

Allowed file types:

  • .calr files (always allowed)
  • .g.cs generated files (build output)
  • Files in obj/ directory (build artifacts)

After initialization, use these Gemini CLI commands:

CommandDescription
@calorWrite new Calor code with Gemini's assistance
@calor-convertConvert existing C# code to Calor syntax

GitHub Copilot (--ai github)

Creates the following files:

FilePurpose
.github/copilot/skills/calor/SKILL.mdCalor code writing skill with YAML frontmatter
.github/copilot/skills/calor-convert/SKILL.mdC# to Calor conversion skill
.github/copilot-instructions.mdProject documentation with Calor-first guidelines
.vscode/mcp.jsonMCP server configuration for Copilot Agent mode

Guidance + MCP Tool Enforcement

GitHub Copilot does not support hooks like Claude Code or Gemini CLI. Calor-first development is guidance-based with MCP tool support.

MCP tools give Copilot programmatic access to the Calor compiler:

  • calor_compile, calor_verify, calor_analyze, calor_convert, calor_typecheck
  • calor_diagnose and calor_validate_snippet for validation
  • Enforcement is not automatic - review file extensions after generation
  • Use calor analyze to find any unconverted .cs files

After initialization, reference skills by name in your prompts:

UsageDescription
Reference calor skillWrite new Calor code with Copilot's assistance
Reference calor-convert skillConvert existing C# code to Calor syntax

MSBuild Integration

The init command adds MSBuild targets to your .csproj file that:

  • Compile .calr files before C# compilation
  • Include generated .g.cs files in the build
  • Clean generated files on dotnet clean

Output Location

Generated C# files are placed in:

Plain Text
obj/<Configuration>/<TargetFramework>/calor/

This keeps generated files out of your source tree.


Examples

Basic Initialization

Bash
# Initialize Calor (MSBuild only)
calor init

# Analyze codebase for migration candidates
calor analyze ./src --top 10

With Claude Code

Bash
# Add Claude Code support
calor init --ai claude

With GitHub Copilot

Bash
# Add GitHub Copilot support
calor init --ai github

Initialize New Project

Bash
dotnet new console -o MyCalorApp
cd MyCalorApp
calor init
calor init --ai claude  # Optional

See Also