Agent skill

Ensure Invariants

by PlamenTSV in PlamenTSV/plamen

Trigger Pattern Always required for DAML audits - Inject Into Breadth agents, depth-edge-case

MITAuto-check passed

Install Ensure Invariants

skills CLI
$ npx skills add PlamenTSV/plamen --skill ensure-invariants -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install PlamenTSV/plamen ensure-invariants --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/PlamenTSV/plamen.git skills-src && mkdir -p .claude/skills && cp -r skills-src/agents/skills/daml/ensure-invariants .claude/skills/ensure-invariants && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
ensure-invariants
GitHub stars
303
Token cost
~1.5k tokens
SKILL.md length
573 words
Files
1
Skills in repo
87
Repo updated
First seen
Licence
MIT

At a glance

Trigger Pattern Always required for DAML audits - Inject Into Breadth agents, depth-edge-case

  • Works in 4 steps: Ensure-Clause Inventory → Boundary Substitution → Cross-Create Consistency → …
  • Pattern Always required for DAML audits - Inject Into Breadth agents
  • SKILL.md covers 1. Ensure-Clause Inventory, 2. Boundary Substitution, 3. Cross-Create Consistency and 4. Deadline / Temporal-Gate…, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Ensure Invariants is an agent skill from PlamenTSV/plamen. Trigger Pattern Always required for DAML audits - Inject Into Breadth agents, depth-edge-case

Its SKILL.md is about 1.5k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

The repository describes itself as: Autonomous Web3 security audit agent for Claude Code. The licence is MIT.

When your agent uses it

  • Pattern Always required for DAML audits - Inject Into Breadth agents
  • Depth-edge-case

Example prompts

  • “/ensure-invariants”

Workflow steps

4 steps, taken from the step headings in SKILL.md.

  1. Ensure-Clause Inventory
  2. Boundary Substitution
  3. Cross-Create Consistency
  4. Deadline / Temporal-Gate Enforcement

What it can do on your machine

Read from SKILL.md and the folder at commit 795962b. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are markdown).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Ensure Invariants loads about 1.5k tokens when it runs. Until then it costs about 28 tokens; SKILL.md has 573 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~28
When it runs · the whole SKILL.md, loaded when a task matches
~1.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from PlamenTSV/plamen at commit 795962b, republished under its MIT licence (© PlamenTSV). 573 words, ~1,515 tokens.

Download SKILL.mdSave it as .claude/skills/ensure-invariants/SKILL.md (or your agent's skills folder).
name
ensure-invariants
description
Trigger Pattern Always required for DAML audits - Inject Into Breadth agents, depth-edge-case

ENSURE_INVARIANTS Skill (DAML)

Trigger Pattern: Always required for DAML audits Inject Into: Breadth agents, depth-edge-case Finding prefix: [DML-EI-N] Rules referenced: R10, R12, R14

A template's ensure clause is its creation precondition: a create whose ensure is False throws PreconditionFailed and the contract never exists. A missing or weak ensure lets an invalid contract enter the ACS (negative amount, empty party list, inconsistent fields), and every downstream choice then trusts the broken invariant. Separately, DAML Int/Decimal arithmetic THROWS on overflow rather than wrapping — so an arithmetic boundary is a liveness/brick bug (the choice aborts and becomes un-exercisable), not a silent-wrap value bug. The PoC for this class is a set of boundary-value Script () functions (min / 1 / negative / max / empty-list), Aptos-style.

1. Ensure-Clause Inventory

For every template, record its ensure and the invariants it should enforce:

Templateensure ExprInvariants It Should EnforceGap?
{T}amount > 0.0 && obs /= [] / NONEamount positive, parties non-empty, fields consistent[DML-EI-N] if invariant unguarded

Critical patterns to flag:

  • No ensure at all on a template carrying an amount/balance/cap → a negative or zero amount contract is creatable ([ELEVATE:ENSURE_GAP]).
  • An ensure that guards some fields but not the security-critical one (e.g., checks amount > 0 but not amount <= cap, or not maintainer non-empty).
  • An invariant assumed by a choice (this.amount > 0) that the ensure does not actually establish.

DAML note: ensure runs on create only. A choice that recreates a successor re-runs the successor's ensure; if the successor template has a weaker ensure, the invariant degrades across the lifecycle.

2. Boundary Substitution

For each ensure-guarded and arithmetic-bearing field, substitute boundary values and trace the outcome:

Template/ChoiceField/ExprValue SubstitutedOutcomeFinding?
{T / T.C}amount / a + b0 / 1 / -1 / maxInt / []created-invalid / abort / wrong-branch[DML-EI-N] if invalid creatable or reachable abort

Substitute and trace:

  • amount = 0 and amount = -1: does the contract create? Does a split produce zero-value children?
  • a + b where both near maxInt/Decimal max: does the choice ABORT (ArithmeticError)? A reachable abort on a user path is a liveness brick ([ELEVATE:ENSURE_GAP] / boundary).
  • empty list ([]) where a non-empty list is assumed (signatories, observers, maintainers): does ensure/the choice handle it, or does a later head/index abort?
Show full SKILL.md (218 more words)Show less

3. Cross-Create Consistency

When several choices create instances of the same template, verify they all establish the same invariant.

TemplateCreated By (choices)All Paths Satisfy Same Invariant?Weakest PathFinding?
{T}{choice list}YES/NO{choice}[DML-EI-N] if one path creates weaker state

Check for:

  • One creation path that bypasses a check another path enforces (asymmetric creation).
  • An accumulator/cap that one creating choice updates but another does not, so the cap is enforced inconsistently (R14).

4. Deadline / Temporal-Gate Enforcement

A deadline is only enforced if a choice actually compares it against getTime.

Template.ChoiceDeadline FieldCompared Against getTime?Comparison RelationEnforced?
{T.C}{deadline}YES/NO< / <= / >[DML-EI-N] if deadline never enforced

Check for ([ELEVATE:DEADLINE_UNENFORCED]):

  • A deadline/maturity/expiry field stored but never read in any choice's guard → the time gate is decorative.
  • A comparison against a caller-supplied time argument instead of getTime (ledger time) — the caller chooses "now".
  • Off-by-one relation (>= vs >) letting an action happen exactly at/after expiry when it should not.

Finding Template

markdown
**ID**: [DML-EI-N]
**Severity**: [High if invalid state corrupts value/cap, Medium if liveness brick or unenforced deadline; Int/Decimal overflow is a LIVENESS finding, NOT auto-downgraded as silent-wrap]
**Step Execution**: ✓1,2,3,4 | ✗(reasons) | ?(uncertain)
**Rules Applied**: [R10:✓/✗, R12:✓/✗, R14:✓/✗]
**Location**: {Module}.daml:LineN (template X)
**Title**: Missing/weak ensure / unenforced deadline on {Template} allows {invalid contract / reachable abort}
**Description**: [The missing precondition or unenforced gate, the boundary value that breaks it, and the downstream choice that trusts the broken invariant]
**Impact**: [Invalid contract enters ACS / arithmetic abort bricks a user path / deadline bypass / cap unenforced]
**PoC steer**: boundary-value Scripts — `boundaryMin/boundaryNeg/boundaryMax : Script ()` calling a shared helper; assert create-invalid SUCCEEDS (ensure gap) or the choice aborts (ArithmeticError, liveness) or the past-deadline action SUCCEEDS (unenforced).

Step Execution Checklist (MANDATORY)

SectionRequiredCompleted?Notes
1. Ensure-Clause InventoryYES✓/✗/?Every template's ensure vs its invariants
2. Boundary SubstitutionYES✓/✗/?0 / 1 / -1 / max / empty-list per field
3. Cross-Create ConsistencyIF template created by 2+ choices✓/✗(N/A)/?All creation paths same invariant
4. Deadline / Temporal-Gate EnforcementIF deadline/expiry field present✓/✗(N/A)/?Compared against getTime, correct relation

© PlamenTSV, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in agents/skills/daml/ensure-invariants of PlamenTSV/plamen.

Open the folder on GitHubat commit 795962b

Compare with similar skills

Ensure Invariants next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Ensure Invariants compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Ensure Invariants this skillPlamenTSV/plamen303—~1.5kAutomated safety check: PassMIT
Golang Patternsaffaan-m/ECC276k—~1.1kAutomated safety check: PassMIT
React Audit Grep Patternsgithub/awesome-copilot40k1 repos~461Automated safety check: PassMIT
Dotnet Patternsaffaan-m/ECC277k1 repos~2.3kAutomated safety check: PassMIT
Fastapi Patternsaffaan-m/ECC276k—~2.3kAutomated safety check: PassMIT
Kotlin Exposed Patternsaffaan-m/ECC277k4 repos~5.5kAutomated safety check: PassMIT

Similar skills

  • Golang Patterns

    affaan-m/ECC

    Go-specific design patterns and best practices including functional options, small interfaces, dependency injection, concurrency patterns, error handling, and package organization.

    276k GitHub stars~1.1k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • React Audit Grep Patterns

    github/awesome-copilot

    Official

    Provides the complete, verified grep scan command library for auditing React codebases before a React 18.3.1 or React 19 upgrade.

    40k GitHub starsUsed in 1 repo~461 tokens
    Auto-check passed
  • Dotnet Patterns

    affaan-m/ECC

    Idiomatic C and .NET patterns, conventions, dependency injection, async/await, and best practices for building robust, maintainable .NET applications.

    277k GitHub starsUsed in 1 repo~2.3k tokens
    DevelopmentAuto-check passed
  • Fastapi Patterns

    affaan-m/ECC

    FastAPI patterns for async APIs, dependency injection, Pydantic request and response models, OpenAPI docs, tests, security, and production readiness.

    276k GitHub stars~2.3k tokensUpdated yesterday
    Backend & APIsAuto-check passed
  • JetBrains Exposed ORM patterns including DSL queries, DAO pattern, transactions, HikariCP connection pooling, Flyway migrations, and repository pattern.

    277k GitHub starsUsed in 4 repos~5.5k tokens
    DatabasesAuto-check passed
  • Python Patterns

    affaan-m/ECC

    Python-specific design patterns and best practices including protocols, dataclasses, context managers, decorators, async/await, type hints, and package organization.

    276k GitHub stars~2.3k tokensUpdated yesterday
    DevelopmentAuto-check passed

More from PlamenTSV/plamen

All 87 skills in this repo
  • Audit Prep

    PlamenTSV/plamen

    Prepare Solidity projects for a security audit — test coverage, test quality, NatSpec docs, code hygiene, dependency health, best-practice enforcement, deployment readiness, and project…

    303 GitHub stars~3.7k tokensUpdated 14 days ago
    Auto-check passed
  • Verification Protocol

    PlamenTSV/plamen

    Trigger Pattern Always (used by all verifier agents) - Inject Into security-verifier agents (Phase 5)

    303 GitHub stars~3.5k tokensUpdated 14 days ago
    Auto-check passed
  • Ability Analysis

    PlamenTSV/plamen

    Trigger Pattern Always (Aptos Move) - foundational security check - Inject Into Breadth agents, depth agents

    303 GitHub stars~3.3k tokensUpdated 14 days ago
    Auto-check passed
  • Ability Analysis

    PlamenTSV/plamen

    Trigger Pattern Always (Sui Move) -- foundational security check - Inject Into Breadth agents, depth agents

    303 GitHub stars~3.2k tokensUpdated 14 days ago
    Auto-check passed
  • Account Lifecycle

    PlamenTSV/plamen

    Trigger Pattern ACCOUNTCLOSING flag detected (close/CloseAccount usage) - Inject Into Breadth agents, depth agents

    303 GitHub stars~1.2k tokensUpdated 14 days ago
    Auto-check passed
  • Account Validation

    PlamenTSV/plamen

    Trigger Pattern Always required for Solana audits - Inject Into Breadth agents, depth agents

    303 GitHub stars~1.7k tokensUpdated 14 days ago
    Auto-check passed

Questions about Ensure Invariants

What does Ensure Invariants do?

Trigger Pattern Always required for DAML audits - Inject Into Breadth agents, depth-edge-case. Ensure Invariants is an agent skill from PlamenTSV/plamen.

When should I use Ensure Invariants?

Ensure Invariants fits situations like: pattern Always required for DAML audits - Inject Into Breadth agents; depth-edge-case.

How do I install Ensure Invariants in Claude Code?

Run `npx skills add PlamenTSV/plamen --skill ensure-invariants -a claude-code`. Or copy the skill folder (agents/skills/daml/ensure-invariants in PlamenTSV/plamen) into .claude/skills/ensure-invariants in your project. Claude Code loads it when a task matches its description.

How do I install Ensure Invariants in Codex?

Run `npx skills add PlamenTSV/plamen --skill ensure-invariants -a codex`. Or copy the skill folder (agents/skills/daml/ensure-invariants in PlamenTSV/plamen) into .agents/skills/ensure-invariants in your project. Codex loads it when a task matches its description.

Can I use Ensure Invariants in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add PlamenTSV/plamen --skill ensure-invariants -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/ensure-invariants, .gemini/skills/ensure-invariants, .github/skills/ensure-invariants and .opencode/skills/ensure-invariants in your project.

What does Ensure Invariants need to run?

SKILL.md names no scripts, command-line tools or credentials: Ensure Invariants is instructions for the agent only.

Does Ensure Invariants access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Ensure Invariants safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Ensure Invariants use?

Ensure Invariants is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Ensure Invariants use?

About 1.5k tokens (SKILL.md is roughly 6.1k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Ensure Invariants?

Skills that share tags, products or a category with Ensure Invariants: Golang Patterns (affaan-m/ECC, 276k stars), React Audit Grep Patterns (github/awesome-copilot, 40k stars), Dotnet Patterns (affaan-m/ECC, 277k stars) and Fastapi Patterns (affaan-m/ECC, 276k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Ensure Invariants?

PlamenTSV (a GitHub user) maintains it in PlamenTSV/plamen, which has 303 GitHub stars. The repository holds 87 skills in this directory. The repository was last updated on September 26, 2026.

Source: PlamenTSV/plamen on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.