plugins/compact-core/skills/compilation-tooling/SKILL.md
Use when working with the Compact compiler (compactc), configuring build settings, understanding zkir/prover/verifier output artifacts, setting up COMPACT_PATH, or integrating VS Code language server support for Midnight smart contract development.
npx skillsauth add aaronbassett/midnight-knowledgebase compact-core:compilation-toolingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Complete guide to the Compact compiler (compactc), project organization, build workflows, and understanding compilation output.
# Compile a contract
compactc contract.compact -o output/
# Compile with debug mode (faster, no ZK proofs)
compactc contract.compact -o output/ --skip-zk
# Generate VS Code language server support
compactc contract.compact -o output/ --vscode
| Flag | Description | Example |
|------|-------------|---------|
| -o, --output | Output directory | -o build/ |
| --skip-zk | Skip ZK proof generation (dev mode) | --skip-zk |
| --vscode | Generate VS Code language server files | --vscode |
| -I, --include | Add include path | -I ./lib |
| --verbose | Verbose output | --verbose |
| --json | JSON output format | --json |
| --no-typescript | Skip TypeScript generation | --no-typescript |
| Variable | Purpose | Example |
|----------|---------|---------|
| COMPACT_PATH | Include path resolution | export COMPACT_PATH="/libs:/project/src" |
| MIDNIGHT_NETWORK | Target network | export MIDNIGHT_NETWORK="testnet" |
Compilation produces several output files:
output/
├── zkir/ # Zero-knowledge intermediate representation
│ ├── circuit_name.zkir # Circuit IR for each exported circuit
│ └── ...
├── keys/
│ ├── prover/ # Prover keys (for proof generation)
│ │ └── circuit_name.pk
│ └── verifier/ # Verifier keys (for on-chain verification)
│ └── circuit_name.vk
├── contract.ts # TypeScript types and contract interface
├── witnesses.ts # Witness type definitions
└── index.ts # Main export file
1. Write Compact contract
2. Compile with --skip-zk for fast iteration
3. Run TypeScript tests
4. When ready: Full compile (generates ZK keys)
5. Deploy to testnet
# Fast iteration (no proof generation)
compactc contract.compact -o build/ --skip-zk
# Full build for deployment
compactc contract.compact -o build/
Recommended project layout for Midnight DApps:
my-midnight-project/
├── contracts/
│ ├── main.compact # Main contract entry point
│ ├── types.compact # Shared type definitions
│ └── lib/ # Helper modules
│ └── utils.compact
├── src/ # TypeScript application code
│ ├── index.ts
│ ├── witnesses.ts # Witness implementations
│ └── deploy.ts
├── build/ # Compiled output (gitignored)
│ ├── zkir/
│ ├── keys/
│ └── *.ts
├── tests/
│ └── contract.test.ts
├── package.json
├── tsconfig.json
└── .env # Environment configuration
Generate language server support for VS Code:
compactc contract.compact -o build/ --vscode
This creates .vscode/ configuration for:
For detailed documentation:
Working project templates and scripts:
tools
Use when setting up Midnight development environment, installing Compact compiler and developer tools, configuring proof server, verifying prerequisites, or getting started with Midnight development.
tools
--- name: midnight-tooling:midnight-debugging description: Use when encountering Midnight errors like "compact: command not found", "ERR_UNSUPPORTED_DIR_IMPORT", version mismatches, proof server failures, "@midnight-ntwrk" package errors, or compilation failures. --- # Midnight Environment Debugging Expert knowledge for identifying and resolving common Midnight development toolchain issues. ## Diagnostic Approach When encountering Midnight-related errors, follow this systematic approach: 1.
tools
Use when checking Midnight version compatibility, understanding pragma language_version, verifying compiler and runtime version relationships, or troubleshooting version mismatch errors between Midnight components.
tools
Use when setting up CI/CD for Midnight projects, configuring GitHub Actions for Compact contract compilation, running TypeScript tests in CI, validating version consistency, or automating contract builds.