Loading...
Loading...
Clarity pre-deployment validation — syntax checking, deprecated keyword detection, sender check analysis, error propagation review, and test verification.
npx skill4agent add aibtcdev/skills clarity-checkcontractbun run clarity-check/clarity-check.ts <subcommand> [options]bun run clarity-check/clarity-check.ts validate --source <path-to-file.clar> [--project-dir <clarinet-project-dir>]--source.clar--project-dirclarinet check{
"file": "contracts/my-contract.clar",
"passed": false,
"checks": [
{
"name": "syntax",
"status": "pass",
"description": "clarinet check passes"
},
{
"name": "deprecated-keywords",
"status": "fail",
"description": "Deprecated keywords found",
"findings": [
{
"line": 15,
"keyword": "block-height",
"replacement": "stacks-block-height",
"severity": "warning"
}
]
},
{
"name": "sender-checks",
"status": "warn",
"description": "Sender check analysis",
"findings": [
{
"line": 22,
"issue": "Token transfer uses contract-caller instead of tx-sender",
"recommendation": "Use tx-sender for token operations to preserve human identity through proxies",
"severity": "warning"
}
]
}
],
"summary": {
"total": 7,
"pass": 5,
"fail": 1,
"warn": 1
}
}bun run clarity-check/clarity-check.ts checklist --source <path-to-file.clar> [--project-dir <clarinet-project-dir>]--source.clar--project-dir{
"file": "contracts/my-contract.clar",
"automated": [
{"check": "clarinet check passes", "status": "pass"},
{"check": "No deprecated keywords", "status": "fail", "details": "Found: block-height on line 15"},
{"check": "Correct sender checks", "status": "warn", "details": "1 finding"},
{"check": "Error propagation uses try!", "status": "pass"},
{"check": "No dead code or unused features", "status": "pass"},
{"check": "Events follow structured format", "status": "pass"},
{"check": "Error codes are unique", "status": "pass"}
],
"manual": [
"Verify tests exist and pass (npm test)",
"Check execution costs in clarinet console (::get_costs)",
"Review post-conditions for all token operations",
"Verify trait whitelisting if external contracts are called",
"Test on testnet before mainnet deployment",
"Document contract address after deployment"
]
}| Check | What it detects |
|---|---|
| Syntax | |
| Deprecated keywords | |
| Sender checks | |
| Error propagation | |
| Dead code | Unused private functions, unreachable branches |
| Event format | Events missing |
| Error code uniqueness | Duplicate error code constants |
| Public function returns | Functions missing |
| Check | Why it matters |
|---|---|
| Tests exist and pass | Ensures behavior is verified |
| Execution costs | Prevents exceeding block limits |
| Post-conditions | Protects users from unexpected token transfers |
| Trait whitelisting | Prevents unauthorized contract interactions |
| Testnet deployment | Catches issues before mainnet |
clarinetclarinetclarity-test-scaffoldclarity-auditclarinet check