Tutorials Search / Building things / Pair-audit Solidity with Claude Code Native + LingModel
πŸ“ Written ● Intermediate Updated 2026-05-21

Pair-audit Solidity with Claude Code Native + LingModel

A two-model workflow for getting your Solidity to the state it deserves before you pay a real auditor. Draft in one model, audit in another, reconcile findings, repeat.

Why pair-audit at all

Smart contract bugs are unusually expensive. Curve lost $73M to a read-only reentrancy the Vyper compiler hadn't been hardened against. Euler lost $200M to a donation-attack pattern that didn't exist as a named category before that exploit. Mango lost $114M to oracle manipulation that any senior auditor would have flagged in five minutes β€” but no one ran one. The pattern repeats: the bug was findable in review, but nobody looked hard enough.

A professional audit at Spearbit, Trail of Bits, OpenZeppelin, or a Code4rena contest costs $20K–$200K and queues 2–6 weeks out. You don't want to show up with code that has obvious reentrancy or missing access modifiers β€” at a contest you're burning collateral, at a private engagement you're paying senior reviewers to write findings you could have caught yourself.

This tutorial's workflow is what to do before that engagement: get the code to a state where the audit finds subtle systemic risk, not onlyOwner typos.

This is not a substitute for a real audit. Two AI models share most of their training data and most of their blind spots. Use this as a CI gate, not as your last line of defense before mainnet. For anything holding meaningful TVL, you still pay for a human audit.

Why two models specifically

One model has blind spots. A second model with a different training mix has different blind spots. The intersection β€” bugs that both miss β€” is smaller than either alone. That's the whole game.

What each tends to be biased toward, in practice:

What you'll learn

Step 1: Pick how you bring Claude

1

Three valid paths β€” pick whichever you already have

LingCode's Claude tab gives you the same agent loop regardless of how Claude is authenticated:

  • BYOK Anthropic API key β€” paste your key in Settings β†’ Providers β†’ Anthropic. Pay-as-you-go.
  • Claude Pro / Max OAuth β€” sign in with your existing Claude.ai subscription. Best if you already pay Anthropic monthly.
  • LingModel Pro tier β€” managed by LingCode. No key wrangling; one subscription for everything.

All three drive the same Node-based agent bridge with full tool use, MCP support, and permission gating. From the audit's perspective, none of these matter β€” pick the cheapest path you can stomach.

Step 2: Enable LingModel as the audit-side provider

2

Sign in and you're done

If you're on the LingModel Pro tier, it appears automatically in the chat's provider switcher next to your Claude option. No key wrangling. Settings (⌘,) β†’ Account confirms the tier is active.

LingModel runs a different model family than Claude Code Native, which is exactly what the audit pass needs β€” fresh priors on the same contract. An audit pass of a 300-line contract is well under $0.10 of LingModel usage.

Step 3: Draft the contract

3

Open a Claude chat and draft normally

Two non-obvious habits make the audit step actually useful:

  • Write the Foundry test file alongside the contract. Both models will reason better about invariants if the tests express them. forge init, contract under src/, test under test/.
  • Put your threat model in a comment block at the top of the contract. Three lines is enough: "This contract holds X. The threat actors are Y. The trust assumption is Z." Now both models have something to attack against.

Example threat-model comment for a vault contract:

// THREAT MODEL
// Holds: depositor USDC, up to ~$50M assumed TVL.
// Trust: governance multisig (5/9) can pause and rotate strategist;
//        no other admin path. Strategist is trusted to not collude.
// Adversaries: depositors trying to mint excess shares (4626 inflation);
//              MEV bots front-running deposit/withdraw; oracle griefers.

Step 4: Switch to LingModel for the audit pass

4

New chat, new provider, no shared context

Click the provider switcher in the chat input area and select LingModel. Open a new chat β€” do not continue the drafting conversation. Sharing context with the model that wrote the code defeats the entire purpose. The audit pass needs to read the contract cold, the way an auditor would.

Paste the contract (and Foundry tests, if you have them) and use a structured prompt rather than "audit this." Vague audit prompts produce vague findings.

Audit this Solidity contract assuming it controls $10M on mainnet.
Check every item below. For each finding, give:
  - Severity (Critical / High / Medium / Low / Info)
  - File:line
  - One-paragraph explanation
  - Concrete fix or mitigation

CHECKLIST
1.  Reentrancy β€” including read-only reentrancy and cross-function
2.  Access control β€” modifier coverage, owner-can-rug surface area
3.  Integer arithmetic β€” even on 0.8.x, unchecked blocks and casting
4.  Oracle dependency β€” staleness checks, manipulation, fallback path
5.  Front-running β€” does any path need commit-reveal?
6.  Signature replay β€” chainId, nonce, deadline, domain separator
7.  Upgrade safety (if proxy) β€” initializer guards, storage gaps, __gap
8.  ERC-4626 share inflation β€” first-depositor griefing, virtual shares
9.  Gas griefing β€” unbounded loops over user-controlled input
10. Checks-Effects-Interactions discipline β€” order of state updates
11. External call return values β€” silent failure modes
12. Token assumptions β€” fee-on-transfer, rebasing, blocklist, ERC-777 hooks
13. Block.timestamp / block.number assumptions
14. tx.origin usage
15. Self-destruct / selfdestruct in dependencies

Output: a numbered findings list. Don't editorialize.

Save LingModel's findings. Then start a fresh chat in Claude with the same checklist prompt and the same contract. You now have two independent findings lists.

Step 5: Reconcile findings

5

Both-flagged β†’ fix. One-flagged β†’ think. Neither-flagged β†’ still possible.

  • Both models flagged the same finding. Fix it. Write a Foundry test that fails on the unfixed version and passes on the fixed one, before moving on. The test is what protects you on future refactors.
  • Only one model flagged a finding. This is where the workflow earns its keep. The lone flagger is right surprisingly often β€” different priors catch what the other missed. Read the finding carefully, write a Foundry test trying to reproduce the issue, and decide based on the test, not the explanation.
  • Neither flagged a category in the checklist. This doesn't mean you're safe β€” it means both models share that blind spot. For Critical-severity categories (reentrancy, access control, oracle), write your own Foundry test against the unfixed assumption anyway.

Loop the process until both models produce only Info-level findings on the latest version. That's your hand-off state to a real auditor β€” clean enough that they spend their hours on systemic risk, not on triage.

Step 6: Add the writing-smart-contracts skill as a third pass

6

Skill Gallery β†’ install writing-smart-contracts

The community skill writing-smart-contracts encodes auditor-grade Solidity heuristics β€” reentrancy patterns, proxy storage collisions, oracle/MEV exposure, ERC-20/721/1155/4626 tokens, deploy-script gotchas β€” and pushes a Foundry test-first workflow. Install it once from the Skill Gallery and it activates in any chat where you mention Solidity, Forge, Hardhat, or an EIP.

Run it as the third pass after the Claude / LingModel reconcile. Same checklist prompt, but now the skill's heuristics steer the model toward categories the bare model would have skimmed. This is genuinely additive β€” it's not a fourth model, it's a sharper system prompt for whichever model you're using.

What this workflow won't catch

Be honest with yourself about the limits before you ship.

Then: get it on Sepolia and stop second-guessing

After the reconcile loop converges, deploy to a testnet and let the contract live there for a week. forge script ... --rpc-url $SEPOLIA_RPC --broadcast --verify, walk the storage layout in Tenderly, watch the events. Real on-chain testing finds gas griefing, MEV exposure, and integration breakage that static review cannot. Then book the audit.

One-liner summary. Draft in Claude, audit in LingModel with a structured checklist, reconcile findings against Foundry tests, run the writing-smart-contracts skill as a final sweep, deploy to Sepolia for a week, then pay for a real audit. The workflow doesn't replace any single step β€” it makes each one cheaper.

Where to go next