The Complete Production SOP: How to Deploy and Run Solhint Solidity Linter & Security Rule Sets in Autonomous AI Agents
Step-by-step SOP to install and run Solhint Solidity Linter & Security Rule Sets in Codex, Claude Code, and Cursor. Enforce smart contract security rules.
Technical Overview & Architectural Context
Autonomous coding agents like Codex, Claude Code, Cursor, and Windsurf frequently hallucinate insecure patterns when writing EVM smart contracts—such as utilizing `tx.origin` for authentication, introducing reentrancy risks, or locking Solidity pragmas inconsistently across Hardhat or Foundry workspaces. Without deterministic guardrails, agents write code that compiles locally but violates strict security standards like OpenZeppelin or ConsenSys guidelines. Integrating the Solhint Solidity Linter & Security Rule Sets skill establishes an impenetrable procedural boundary. It compels autonomous agents to instantiate strict `.solhint.json` configs, audit abstract syntax trees for anti-patterns before committing code, and parse output diagnostics deterministically. By leveraging declarative YAML triggers, this skill converts loose developer prompts into deterministic linting, security checking, and auto-correction loops. This guarantees zero non-compliant Solidity PRs enter production pipelines.
Prerequisites & Environment Requirements
Verified Search Intents & Long-Tail Queries Solved
This operational tutorial is engineered to provide deterministic solutions for these developer search queries:
Step-by-Step Execution Playbook
Local Environment Setup & SKILL.md Mounting
Create the local skill manifest directory and inject verified procedural rules into agent runtime contexts.
Autonomous agents discover domain skills by scanning local manifests at initialization. Placing `SKILL.md` inside `.agents/skills/solhint-linter-best-practices/` allows Codex, Claude Code, Cursor, and Windsurf to index triggers, understand execution constraints (`fs_read: true`, `fs_write: 'workspace'`), and restrict untrusted operations.
mkdir -p .agents/skills/solhint-linter-best-practices && curl -fsSL https://askills.dev/api/skills/solhint-linter-best-practices/raw -o .agents/skills/solhint-linter-best-practices/SKILL.md---
name: "solhint-linter-best-practices"
description: "Enforce Solidity code quality, style guides, and security rules with Solhint."
metadata:
author: "Protofire"
version: "1.0.0"
runtime_compatibility:
- "codex"
- "claude-code"
- "cursor"
- "windsurf"
triggers:
- "run solhint linter"
- "configure .solhint.json"
- "fix solidity security warnings"
permissions:
fs_read: true
fs_write: "workspace"
shell_exec: false
net_access: false
---
# Solhint Solidity Linter & Security Rule Sets
Lints smart contracts with Solhint: enforcing compiler version pragma rules, gas optimization warnings, avoiding tx.origin, and enforcing OpenZeppelin and ConsenSys security guidelines.
## When to Invoke
Invoke this skill whenever you need to:
- run solhint linter
- configure .solhint.json
- fix solidity security warnings
## Execution SOP & Rules
1. Initialize configuration: npx solhint --init or verify existing .solhint.json.
2. Extend recommended security rules: {"extends": "solhint:recommended"} in .solhint.json.
3. Run npx solhint 'contracts/**/*.sol' in CI pipelines or local checkpoints.
4. Forbid use of tx.origin for authorization; enforce msg.sender exclusively.
## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries.
- Verify tests or build commands exit cleanly with return code 0.Keep the SKILL.md focused on deterministic procedural instructions. Do not bloat it with Solidity code examples; the agent already contains Solidity knowledge and only needs procedural boundaries.
Ensure `.agents/skills` is located in the root of the workspace directory. Sub-directory placements will cause Cursor and Windsurf indexing engines to bypass the skill manifest.
Dependency Validation & Baseline Configuration
Install Solhint locally and generate the recommended security configuration file.
Agents require a local Solhint binary to prevent version drift between CI environments and agent sandboxes. Running `npm install -D solhint` ensures deterministic rule enforcement, followed by injecting `.solhint.json` with strict security rulesets.
npm install --save-dev solhint && npx solhint --init{
"extends": "solhint:recommended",
"plugins": [],
"rules": {
"compiler-version": ["error", ">=0.8.20"],
"avoid-tx-origin": "error",
"no-inline-assembly": "warn",
"reentrancy": "error",
"state-visibility": "error",
"func-visibility": ["error", { "ignoreConstructors": true }]
}
}Define strict error thresholds for 'avoid-tx-origin' and 'reentrancy' to trigger automatic exit codes (exit code 1) on rule violations during agent self-correction steps.
Avoid setting global npm installations inside agent workflows. Sandbox execution environments usually lack root write access to `/usr/local/lib/node_modules`.
Intent Matching & Trigger Invocation
Verify deterministic activation using tested natural language prompts.
When an agent processes developer requests, semantic matchers evaluate the triggers declared in frontmatter. Using exact phrase anchors like 'run solhint linter' or 'configure .solhint.json' activates the SOP ruleset immediately.
npx solhint 'contracts/**/*.sol'Use concise verbs matching the frontmatter triggers: 'run solhint linter and fix solidity security warnings on Vault.sol'.
Quote the glob path ('contracts/**/*.sol') to avoid shell expansion issues across zsh, bash, and Windows PowerShell.
Verification, Linting & Output Quality Gate
Execute automated self-healing checks before accepting agent deliverables.
The agent must parse Solhint output, extract warnings/errors, patch the AST or Solidity source files directly, and re-run the verification command until return code 0 is achieved.
npx solhint 'contracts/**/*.sol' --max-warnings 0// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract Vault {
address public immutable owner;
error Unauthorized();
constructor() {
owner = msg.sender;
}
function withdraw() external {
// Solhint compliance: msg.sender enforced over tx.origin
if (msg.sender != owner) revert Unauthorized();
payable(msg.sender).transfer(address(this).balance);
}
}Supply the `--max-warnings 0` flag to agent workflows so minor style warnings do not accumulate as technical debt.
Never allow agents to bypass rules with `/* solhint-disable */` comments without explicit human confirmation.
Real-World Scenario: Automated Remediation of Insecure Authentication in Staking Contracts
“Run solhint linter across contracts/StakingPool.sol, fix solidity security warnings, and ensure compliance with solhint:recommended.”
Runtime Troubleshooting & Failure Modes
Root Cause: The agent attempted to execute `npx solhint` before local project initialization, or '.solhint.json' does not exist in the root context.
npm install --save-dev solhint && npx solhint --initRoot Cause: Shell globbing failed due to missing quotes in the command or contracts residing in a custom directory (e.g., `src/` in Foundry projects).
npx solhint "src/**/*.sol" || npx solhint "contracts/**/*.sol"Frequently Asked Questions (Solhint Solidity Linter & Security Rule Sets SOP)
Q:Can I use Solhint Solidity Linter & Security Rule Sets across Codex, Claude Code, and Cursor simultaneously?
Yes. The skill conforms to the universal SKILL.md specification. Once installed under `.agents/skills/solhint-linter-best-practices/SKILL.md`, Codex, Claude Code, Cursor, and Windsurf can load and execute the rule definitions seamlessly.
Q:How does Solhint Solidity Linter & Security Rule Sets prevent context window overflow during long agent sessions?
Instead of injecting multi-page Solidity style manuals directly into the LLM system prompt, this skill establishes a concise 4-step procedural gate and CLI invocation. The agent relies on Solhint's deterministic CLI output rather than raw context memory to detect and fix bugs.
Q:Does this skill require escalated root or container permissions?
No. The skill receives an audited security score of 98/100. It requires zero network access (`net_access: false`), no escalated root shell execution (`shell_exec: false`), and limits write privileges strictly to workspace files (`fs_write: 'workspace'`).
Ready to equip your autonomous agent with Solhint Solidity Linter & Security Rule Sets?
Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.