plugins/compact-core/skills/language-reference/SKILL.md
Use when writing Compact smart contracts and need reference for primitive types (Field, Boolean, Uint), composite types (struct, enum, Vector, Bytes), circuit/witness syntax, control flow (if/else, for loops, assert), or module system (import, include, export).
npx skillsauth add aaronbassett/midnight-knowledgebase compact-core:language-referenceInstall 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 reference for the Compact smart contract language used on Midnight Network.
| Type | Description | Example |
|------|-------------|---------|
| Field | ZK-native field element (~254 bits) | const f: Field = 42; |
| Boolean | True/false value | const b: Boolean = true; |
| Uint<N> | Unsigned integer (N bits, N ≤ 248) | const n: Uint<64> = 100; |
| Type | Description | Example |
|------|-------------|---------|
| Bytes<N> | Fixed-size byte array | const h: Bytes<32> = ...; |
| struct | Named record type | struct Point { x: Field, y: Field } |
| enum | Tagged union | enum Maybe<T> { Some(T), None } |
| Vector<T, N> | Fixed-size array | const v: Vector<Field, 3> = [1, 2, 3]; |
| Type | Description | Example |
|------|-------------|---------|
| Opaque<'string'> | UTF-8 string from TypeScript | witness get_name(): Opaque<'string'>; |
| Opaque<'Uint8Array'> | Binary data from TypeScript | witness get_data(): Opaque<'Uint8Array'>; |
// Public circuit callable from TypeScript
export circuit transfer(to: Bytes<32>, amount: Uint<64>): [] {
// Circuit body
}
// Private helper circuit
circuit helper(x: Field): Field {
return x * x;
}
// Declaration (implemented in TypeScript)
witness get_private_key(): Bytes<32>;
// Usage in circuit
export circuit sign(message: Bytes<32>): Bytes<64> {
const key = get_private_key();
// Use key...
}
// Conditional
if (condition) {
// then branch
} else {
// else branch
}
// Bounded loop (bounds must be compile-time constant)
for i in 0..10 {
// loop body
}
// Assertion
assert condition, "Error message";
// Import specific items
import { hash } from "CompactStandardLibrary";
// Include entire file
include "utils.compact";
// Export for external use
export circuit public_fn(): Field { ... }
For detailed documentation on each topic:
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.