clarity-governance
Skill2 starsChanged 31 days agoMITView on GitHub
Governance and admin control for Clarity protocols on Stacks: DAO proposals, multisigs, timelocks and 2-step ownership. Use for DAOs, proposals, multisigs, admin roles or owner transfer.
In this repository24 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- clarity-apisSkill
- clarity-assetsSkill
- clarity-auditorSkill
- clarity-bitcoin-proofsSkill
- clarity-deploymentSkill
- clarity-ecosystemSkill
- clarity-environmentsSkill
- clarity-epochsSkill
- clarity-fuzzingSkill
- clarity-optimizerSkill
- clarity-oraclesSkill
- clarity-protocolsSkill
- clarity-scholarSkill
- clarity-securitySkill
- clarity-sip-complianceSkill
- clarity-stakingSkill
- clarity-startSkill
- clarity-system-integrationSkill
- clarity-testingSkill
- clarity-upgradesSkill
- clarity-walletsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. About 0 are common, 12 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈12
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 29
Token voting: only when holder voting is a product requirement.
- Distinctive: line 40
Treat broad executor asset authority as an explicit governance trust decision, never a generic integration workaround.
- Distinctive: line 41
Test direct and routed signers, malicious proposals, wrong-role traits, repeated execution, removed members, threshold changes, exact …
- Very specific: line 51
Read upstream notes before reusing ExecutorDAO source (legacy as-contract, block-height), and the Zest v2 adaptation before integrating or
- Distinctive: line 121
Test: non-member propose, duplicate approval, below threshold, early execution, wrong script, repeat execution, removed member.
- Distinctive: line 131
Read Granite action governance before integrating or reviewing Granite.
- Very specific: line 148
Read native multisig transactions when building or signing one: every signer keeps the same public-key order and reviews the same payload.
- Distinctive: line 155
If the intended contract cannot accept ownership, use an explicitly authorized direct contract-owner setter or extend its governance route.
- Very specific: line 157
Use contract-caller for the owner and nominee checks, so a malicious intermediary cannot act through the owner's tx-sender.
- Distinctive: line 179
Prefer staged changes for sensitive authority/configuration: authorize and bind the payload, expose a review window, then execute the …
- Distinctive: line 184
Test cancellation followed by replacement, same-key duplicates, independent keys, and owner transfer with pending actions.
- Distinctive: line 185
Test nominee reachability and old-owner revocation through the real call chain.
- Distinctive: line 186
Keep delay reductions subject to the existing delay and above the coded minimum.
- Distinctive: line 188
Read the Hermetica hBTC example for a worked request, delay and confirmation design, or before integrating Hermetica.
- Distinctive: line 198
Do not pause during a multisig compromise: users could not exit, and the team would have to cancel the attacker's proposals indefinitely.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Clarity Governance
Separate the representation of an approved action from the mechanism that authorizes it.
Writing or changing contract code: also load clarity-scholar and clarity-security, and finish with the build checklist.
Key distinctions
- A native Stacks multisig is a standard principal with transaction-level signature rules; it is not a Clarity multisig contract.
- A trait-compatible proposal is executable code, not evidence of an approved or safe action.
- Current membership, historical approvals, threshold changes and timelocks must have explicit semantics.
- A timelock in Stacks blocks is not an exact wall-clock duration.
Default decision rule
- Protocol holding user funds: contract-owned M-of-N approval plus a timelock on sensitive changes: code and upgrades, roles, and anything touching prices, oracles, tokens or custody; the protocol defines what else counts. Recommend at least 24 hours for operational changes and at least 48 hours (172800 s) for upgrades and custodial changes, counted from the approval that makes the action executable; lengthen it when users need more time to exit. It must also have an instant pause that a guardian or keeper can trigger with no delay; pausing and cancelling a pending proposal are the only immediate actions.
- Fixed, short action list: action-based governance or timelocked setters (set fee, change role, switch logic contract).
- Open-ended actions: the proposal-contract executor, with the multisig and timelock as its extension.
- Native multisig: good for deployer and operational keys (deployment, pause). As a long-term owner, pair it with an on-chain timelock or staged administration and plan an ownership transfer for every signer change: changing keys or threshold derives a new principal, and native authorization adds no delay (comparison).
- Token voting: only when holder voting is a product requirement. Never count votes from current-block balances, or a flash loan can borrow, vote and repay in one transaction; use balances recorded before the proposal opened.
- Ownership of any single role: nominate then accept, with events; for roles that move funds or report value, acceptance completes only after the protocol timelock (two-step ownership).
Choose and implement
- Provide role setters and reachable ownership handoff: prefer nominee acceptance for accounts; contract nominees need an executable acceptance/admin route or an explicitly authorized direct handoff.
- For account-only nominees, check
(is-none (get name (unwrap! (principal-destruct? p) ERR)))as in the fragment below;is-standardalso accepts contracts. Allow contract administrators when the policy requires them. - Bind target contracts, assets, parameters, proposal identity, network/domain and replay state to the approval.
- Trace signer → governance → executor → proposal → target. Distinguish
tx-sender,contract-callerand deliberate executor context. - Define proposal creation, duplicate approval handling, eligibility, threshold snapshots/current rules, cancellation, expiry, execution-once and emergency powers.
- Confirm actual deployed proposal source and successful deployment. A source payload in a failed transaction is insufficient (A05).
- Treat broad executor asset authority as an explicit governance trust decision, never a generic integration workaround.
- Test direct and routed signers, malicious proposals, wrong-role traits, repeated execution, removed members, threshold changes, exact timelock boundaries, failed legs and emitted events (test cases).
- Rehearse initialization and authority handoff through the deployment workflow. Test fixtures must not become production signer/threshold defaults.
Proposal-contract DAO
ExecutorDAO pattern (Marvin Janssen's ExecutorDAO):
- Each action is a new immutable contract implementing the proposal trait's
executefunction. The core executes proposals and tracks enabled extensions; extensions supply submission, voting, emergency execution and other policies. The core does not mandate one voting or multisig model. - A proposal can coordinate several privileged operations atomically when they fit one transaction's budget. New action combinations need not be pre-enumerated, but approved code gets the executor's effective authority.
- The privileged check accepts the DAO sending context or an enabled immediate extension caller. Enabling an extension grants it the DAO's authority.
- Read upstream notes before reusing ExecutorDAO source (legacy
as-contract,block-height), and the Zest v2 adaptation before integrating or reviewing Zest.
Minimal Clarity 4 layout: a core, a multisig-plus-timelock extension and one proposal contract per action. Deploy the core and extension, then the first proposal, then call construct once.
Core (dao-core):
- Proposal trait:
(define-trait proposal-trait ((execute (principal) (response bool uint)))). - State:
executive(data var, the deployer untilconstruct),executed-proposals(proposal principal →stacks-block-heightof execution),extensions(principal → bool). Read-onlyis-extensionandexecuted-at. is-self-or-extension:(or (is-eq tx-sender current-contract) (is-extension contract-caller)), the DAO itself (inside a proposal) or an enabled extension.runexecutes a proposal once (map-insertintoexecuted-proposals, elseERR_ALREADY_EXECUTED), prints, then calls itsexecuteinsideas-contract?, so the DAO istx-senderandcontract-callerof the proposal.with-all-assets-unsafegives proposals the DAO's full asset authority: use()if they never move the core's assets.set-extension (extension, enabled)is reachable only through a proposal or another extension, and prints.execute (proposal, sender)is the entry point for extensions.construct (proposal)is the one-time bootstrap by the deployer: it handsexecutivetocurrent-contractand runs the first proposal, which installs the extensions.
;; fragment: ExecutorDAO-style core, adapted to Clarity 4
(define-trait proposal-trait ((execute (principal) (response bool uint))))
;; The DAO itself (inside a proposal) or an enabled extension.
(define-private (is-self-or-extension)
(ok (asserts! (or (is-eq tx-sender current-contract) (is-extension contract-caller)) ERR_UNAUTHORIZED)))
;; Run a proposal once, with the DAO as tx-sender and contract-caller of the proposal.
(define-private (run (proposal <proposal-trait>) (sender principal))
(begin
(asserts! (map-insert executed-proposals (contract-of proposal) stacks-block-height) ERR_ALREADY_EXECUTED)
(as-contract? ((with-all-assets-unsafe)) ;; narrow this when proposals never move assets
(try! (contract-call? proposal execute sender)))))
;; construct: (asserts! (is-eq tx-sender (var-get executive)) ERR_UNAUTHORIZED),
;; then (var-set executive current-contract) and run the first proposal.Multisig extension (dao-multisig):
- State:
members(principal → bool),proposals(id →{ script, mature-at, approvals, executed },mature-atu0= not yet approved),approved({ id, member }→ bool),next-id. Example policy:THRESHOLD u2,DELAY_SECONDS u172800(48 hours, the upgrade minimum above). set-memberchecks(is-eq tx-sender .dao-core): membership changes arrive as DAO proposals, wheretx-senderis the DAO (a deliberate executor context). Everything else usescontract-caller.propose (script <proposal-trait>): a member registers the proposal principal; the proposer counts as the first approval.approve (id): member only, not executed, one approval per member (map-insertintoapproved, elseERR_ALREADY_APPROVED). The approval that reaches the threshold starts the review window.execute (id, script): anyone may execute a matured, approved proposal. The stored script principal is binding; it marks the proposal executed before calling(contract-call? .dao-core execute script tx-sender).cancel (id): members approve a cancellation the same way; the approval that reaches the threshold closes the pending proposal at once (immediate actions).- Changing
THRESHOLD, the delay or the member set policy is itself a proposal (or a new extension), subject to the same delay.
;; fragment: multisig extension
;; approve: reject a duplicate, then the approval that reaches THRESHOLD starts the delay
(asserts! (map-insert approved { id: id, member: contract-caller } true) ERR_ALREADY_APPROVED)
(merge p { approvals: approvals,
mature-at: (if (and (is-eq (get mature-at p) u0) (>= approvals THRESHOLD)) (+ stacks-block-time DELAY_SECONDS) (get mature-at p)) })
;; execute: anyone, once, with the stored script, after the delay
(define-public (execute (id uint) (script <proposal-trait>))
(let ((p (unwrap! (map-get? proposals id) ERR_NOT_FOUND)))
(asserts! (is-eq (contract-of script) (get script p)) ERR_WRONG_SCRIPT)
(asserts! (not (get executed p)) ERR_EXECUTED)
(asserts! (and (>= (get approvals p) THRESHOLD) (> (get mature-at p) u0)) ERR_THRESHOLD)
(asserts! (>= stacks-block-time (get mature-at p)) ERR_TIMELOCK)
(map-set proposals id (merge p { executed: true }))
(contract-call? .dao-core execute script tx-sender)))Proposal contracts:
- A proposal is an ordinary contract implementing the trait, deployed, approved and executed once. The first one installs the multisig; later proposals call your protocol's setters.
- Those setters must accept the DAO as caller:
tx-senderis the DAO andcontract-calleris the proposal contract, so downstream admin checks comparetx-senderwith the DAO.
;; fragment: installs the multisig; add every signer (at least THRESHOLD)
(impl-trait .dao-core.proposal-trait)
(define-public (execute (sender principal))
(begin
(try! (contract-call? .dao-core set-extension .dao-multisig true))
(try! (contract-call? .dao-multisig set-member sender true))
(ok true)))- Test: non-member propose, duplicate approval, below threshold, early execution, wrong script, repeat execution, removed member.
Action-based governance
- A persistent contract stores proposal IDs, action codes, typed parameter data, approvals/denials, expiry and execution state. A dispatcher executes a finite set of supported operations when the selected threshold and timelock policy pass.
- This narrows the available actions and avoids a contract deployment per proposal. New action kinds can require a governance implementation change.
- Approval can immediately execute an eligible action or schedule it for later, depending on its configured timelock. Do not assume every approval is a pure vote.
- Proposal/member-count snapshots, current membership checks and threshold arithmetic must agree. Test member removal/addition, duplicate votes, small signer sets and threshold boundary rounding.
- Guardian pause roles differ from governance members (immediate actions).
- Bind proposal ID to nonce/action/parameters; test that one approved ID cannot be reused with different payloads.
- Read Granite action governance before integrating or reviewing Granite.
Contract multisig versus native multisig
| Property | Clarity contract multisig | Native Stacks multisig principal |
| Identity | deployer.contract-name | Standard address starting SM (mainnet) or SN (testnet) |
| Threshold enforcement | Contract code and stored membership/proposals | Transaction authorization signature condition |
| Approval flow | Often multiple approval transactions plus execution | Multiple signatures authorize one transaction origin |
| Policies | Can implement timelocks, role limits, cancellation, spend rules | Native authorization alone supplies no DAO timelock or action policy |
| Signer changes | Contract can retain identity while changing membership | Threshold or key-set changes derive a different principal; plan authority migration |
| Call context | Immediate caller can be the multisig/executor contract; sender depends on context scopes | The signed transaction origin is the native multisig principal; routing still changes immediate caller |
| Deployments | A contract is not a top-level transaction signer; it governs calls by execution | A native multisig can sign a deployment, producing contracts under its SM or SN address |
is-standarddoes not identify single-sig versus multisig or contract identity.SM/SNare P2SH version bytes, also used by P2SH-wrapped single keys:(get version (unwrap-panic (principal-destruct? p)))of0x14(mainnet) or0x15(testnet) shows a script-hash address, not proof of a multisig. Inspect intended principal type and verified authorization design.- Clarity does not expose the full native multisig's pubkey/signature configuration through the principal alone.
- A contract multisig can include a native multisig principal as a member; these layers then enforce distinct thresholds.
- Read native multisig transactions when building or signing one: every signer keeps the same public-key order and reviews the same payload; non-signing keys are appended with
appendOrigin.
Two-step ownership
- Initialize privileged roles in data vars, commonly
tx-senderfor the deployer. Provide authenticated replacement/removal as appropriate; immutable authority requires an explicit design reason. - For standard-principal owners, prefer current-owner nomination followed by nominee acceptance. Test old-owner revocation and rejection of repeated acceptance.
- Contract nominees need a real authorized entry point that calls the target's acceptance function, so the nominee is the immediate caller of
accept-owner. A simulated contract principal supplied as transaction sender does not prove reachability. - If the intended contract cannot accept ownership, use an explicitly authorized direct contract-owner setter or extend its governance route. Verify it can perform later administration too.
- Restrict account-nomination/direct-contract setters to their intended principal kinds and networks with
principal-destruct?(wrong-network principals fail there);is-standarddoes not distinguish these kinds. - Use
contract-callerfor the owner and nominee checks, so a malicious intermediary cannot act through the owner'stx-sender. Under an ExecutorDAO-style owner the DAO arrives astx-sender; compare that with the DAO as in proposal contracts. - Clear stale nominations on completed handoff; let the owner cancel an unaccepted nomination. Emit actor, previous and new authority using the project's event schema. Test unauthorized calls, contract routes, replacement/cancellation policy and revocation.
;; fragment: two-step ownership for a standard-account owner (owner, pending-owner data vars)
(define-public (nominate-owner (nominee principal))
(let ((parts (unwrap! (principal-destruct? nominee) ERR_NOT_ACCOUNT)))
(asserts! (is-eq contract-caller (var-get owner)) ERR_UNAUTHORIZED)
(asserts! (is-none (get name parts)) ERR_NOT_ACCOUNT) ;; drop to allow contract nominees
(print { event: "owner-nominated", owner: (var-get owner), nominee: nominee })
(ok (var-set pending-owner (some nominee)))))
(define-public (accept-owner)
(let ((previous (var-get owner)))
(asserts! (is-eq (some contract-caller) (var-get pending-owner)) ERR_UNAUTHORIZED)
(var-set owner contract-caller)
(var-set pending-owner none)
(print { event: "owner-changed", previous: previous, owner: contract-caller })
(ok true)))Staged administration
- Prefer staged changes for sensitive authority/configuration: authorize and bind the payload, expose a review window, then execute the stored action.
- Separate two protections: a timelock provides time to react; nominee acceptance proves the new authority can act. Two calls by the same owner provide no independent approval.
- Changes outside the protocol's sensitive set need no staging.
- Permissionless confirmation executes previously authorized data; it does not grant permission to choose new settings.
- Reject unauthorized requests/cancellation, premature execution, mismatched payloads and repeated execution.
- Test cancellation followed by replacement, same-key duplicates, independent keys, and owner transfer with pending actions.
- Test nominee reachability and old-owner revocation through the real call chain; simnet sender strings do not prove wallet/multisig signing capability.
- Keep delay reductions subject to the existing delay and above the coded minimum. Test exact clock boundaries, the immediate actions and monitoring events.
- Recheck dependent constraints at execution or prove they remain invariant while requests are pending.
- Read the Hermetica hBTC example for a worked request, delay and confirmation design, or before integrating Hermetica.
Immediate actions
Two actions skip the timelock, because each can only stop something. Every other sensitive change waits for it, and its minimum delay is a constant in code that no proposal can lower.
- Guardian pause: guardians (or keepers) can only pause, and do it at once. Pair them with automated monitoring that triggers the pause, such as Hypernative. A compromised guardian can only pause: the protocol stays paused until governance replaces the guardian and unpauses, two timelocked proposals that run in parallel.
- Cancellation: the governing multisig closes any pending proposal as soon as its threshold approves. If an attacker reaches the threshold while the team still holds enough keys, the team cancels each malicious proposal during its delay, and users exit meanwhile.
- One multisig governs everything else through the timelock: damaging operations, guardian changes, member and threshold changes, and migration to a new multisig.
- Unpause through the timelock by default, at least 24 hours, so a malicious unpause can be cancelled. A faster unpause is the project's choice to disclose (Granite unpauses on approval).
- Do not pause during a multisig compromise: users could not exit, and the team would have to cancel the attacker's proposals indefinitely. No design survives the guardians and the multisig compromised together; disclose that residual risk.
- Any other path around the delay (an urgent flag, emergency execution, an instant delay cut) is a timelock bypass: disclose it as a trust exception, and report it in reviews.
Signer and proposal transitions
- Enforce unique members and a reachable, nonzero threshold at bootstrap and every update. Respect list/buffer capacities and any weighted-vote rules.
- Count approvals by signer identity, not signature count. A valid signer subset need not occupy the same list indexes as the full roster; each weight must come from the authorized roster.
- Specify whether pending proposals retain snapshot membership/thresholds or use current configuration. Test removal, re-addition, threshold changes and expiry before execution.
- Preserve action/parameter binding, execution-once state and cancellation through implementation changes. Test that authorized governance can actually reach every required setter through its complete call chain.
- Recheck dependent configuration at execution; another approved action may have changed it since scheduling.
- For contract replacement, state/custody migration and old-token compatibility, use Clarity Upgrades. Recommend timelocks for code upgrades and equivalent registry/role grants; pausing stays an immediate action.
Governance test cases
- Initialization exactly once by the intended authority; signer membership and threshold match the approved deployment policy.
- Missing/duplicate approval; expired/cancelled/already-executed proposal; wrong script principal or changed action data.
- Membership/threshold changes before execution; signer forwarding through an untrusted contract.
- Just before, at and after maturity/expiry with the actual clock.
- Guardian pauses at once and can do nothing else; cancellation at the threshold takes effect at once; unpause, guardian and member changes wait for the delay; a delay below the coded minimum is rejected.
- Failed middle action rolls back the intended transaction; separately submitted transactions remain independently committed.
- Narrow asset movement, expected admin events, preserved error provenance, post-upgrade replay protection and continuing control of treasury/registries.
Read when needed
- Versions: context scopes and clocks.
- Security patterns: authority, role confusion and deployed-source evidence.
- Protocol examples (ExecutorDAO upstream, Zest, Granite, Hermetica).
Reference baseline
Examples use Clarity 4+ syntax unless marked, checked on epoch 4.0. Source links in this skill use these pins; links into sibling skills use their owner's SKILL.md. Review dates do not renew live evidence.
stacks-core: ccf31dc69c.executor-dao: 4676718828.zest-v2: f2fce52672.granite: 2d44a2df94.hermetica: 5e13e431f6.sips: 642af6804d.stacks-js-wallets: e6084a5214.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

