plugins/compact-reviewer/skills/design-architecture/SKILL.md
Use when reviewing Compact contract architecture, evaluating design patterns, assessing modularity, or analyzing API design and code organization quality.
npx skillsauth add aaronbassett/midnight-knowledgebase compact-reviewer:design-architectureInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
4 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Evaluate contract structure, design patterns, and architectural quality.
This skill activates for queries about:
Trigger words: architecture, design pattern, structure, modularity, organization, layout, API design
| Aspect | Check | Severity | |--------|-------|----------| | Separation of concerns | Each circuit has one responsibility | 🟡 Medium | | State encapsulation | Ledger access is controlled | 🟠 High | | Clear interfaces | Export circuits have clear purposes | 🟡 Medium | | Naming conventions | Circuits/ledgers clearly named | 🟢 Low | | Documentation | Public interfaces documented | 🟢 Low |
// ✅ Single responsibility circuits
export circuit deposit(amount: Uint<64>): [] { }
export circuit withdraw(amount: Uint<64>): [] { }
export circuit get_balance(): Uint<64> { }
// ✅ Helper circuits for reusable logic
circuit verify_owner(): [] {
const caller = get_caller_secret();
assert hash(caller) == owner_hash.read();
}
// ✅ Clear state organization
ledger balances: Map<Bytes<32>, Uint<64>>;
ledger config: Cell<Config>;
ledger admin: Cell<Bytes<32>>;
// ❌ God circuit - does too much
export circuit do_everything(
action: Uint<8>,
arg1: Field,
arg2: Field,
arg3: Field
): Field {
if action == 0 { /* deposit */ }
if action == 1 { /* withdraw */ }
if action == 2 { /* transfer */ }
// ...
}
// ❌ Unclear naming
export circuit proc(x: Field): Field { }
ledger d: Map<Bytes<32>, Uint<64>>;
Evaluate overall organization:
1. Count exported circuits - too many (>10) suggests splitting
2. Check circuit sizes - >50 lines may be too complex
3. Verify helper circuits are used appropriately
4. Confirm ledger declarations are grouped logically
Identify common patterns:
| Pattern | Indicators | Quality |
|---------|------------|---------|
| Owner pattern | owner_hash, verify_owner() | ✅ Good |
| Access control | Role-based checks | ✅ Good |
| Upgrade pattern | implementation ledger | ⚠️ Complex |
| Multi-sig | Multiple signatures required | ✅ Good |
| State machine | Enum-based state | ✅ Good |
Check public API:
1. Are circuit names descriptive?
2. Are parameters minimal and clear?
3. Is return type appropriate?
4. Are related operations grouped?
Evaluate separation:
1. Can logic be tested independently?
2. Are concerns separated?
3. Is state access controlled?
4. Are dependencies explicit?
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.