Claude Skills Guide

Claude Code for Compound Governance Workflow

Automating decentralized governance is one of the most powerful use cases for Claude Code in the Web3 space. Compound’s governance model—which relies on proposers, delegates, and executors—lends itself perfectly to Claude-assisted automation. This guide walks you through building a complete governance workflow using Claude Code, from drafting proposals to executing passed measures.

Understanding Compound Governance Architecture

Compound’s governance operates on a three-phase model: proposal submission, voting period, and execution. The protocol uses COMP tokens as voting power, with delegates able to cast votes on behalf of token holders. Before automating, you need to understand how these components interact:

Claude Code can interact with all three through a combination of RPC calls and local file operations for proposal drafting.

Setting Up Your Governance Skill

Create a specialized skill for governance operations. This skill should handle both the off-chain drafting and on-chain interaction aspects:

---
name: compound-governance
description: Manage Compound governance proposals and voting
---

This skill declaration restricts tool access to file operations and bash—enough to draft proposals locally while keeping governance calls isolated in executable scripts.

Proposal Drafting Workflow

The first governance task Claude Code excels at is proposal drafting. Rather than manually writing Solidity and configuration files, you can automate the entire drafting process:

Step 1: Define Proposal Parameters

Create a configuration-driven approach where proposal details live in structured files:

{
  "proposal": {
    "title": "Increase USDC Collateral Factor",
    "description": "Increase the collateral factor for USDC from 75% to 80% to improve capital efficiency.",
    "targets": ["0x39AA39c419df9D5B5A9D46f1bA1dD4e2bF3d8E1c"],
    "values": ["0"],
    "signatures": ["_setCollateralFactor(address,uint256)"],
    "calldatas": ["0x000000000000000000000000A0b86991c6218b36c1d19D4a2e9Eb0cE3606eB480000000000000000000000000000000000000000000000000000000000000050"],
    "voteStart": 1682000000,
    "voteDuration": 199080
  }
}

Step 2: Generate Proposal Script

Use Claude Code to generate the executable JavaScript that submits your proposal:

const { ethers } = require('ethers');
const fs = require('fs');

async function propose(config) {
  const provider = new ethers.JsonRpcProvider(process.env.RPC_URL);
  const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
  
  const governor = new ethers.Contract(
    config.governanceAddress,
    ['function propose(address[],uint256[],string[],bytes[],string) returns (uint256)'],
    wallet
  );
  
  const tx = await governor.propose(
    config.proposal.targets,
    config.proposal.values,
    config.proposal.signatures,
    config.proposal.calldatas,
    config.proposal.description
  );
  
  const receipt = await tx.wait();
  console.log(`Proposal created: ${receipt.hash}`);
  return receipt;
}

module.exports = { propose };

Step 3: Automate Execution

Combine everything into a bash script that Claude Code can execute:

#!/bin/bash
# Governance proposal submission script

CONFIG_FILE=$1
PROPOSAL_ID=$(node submit-proposal.js "$CONFIG_FILE")
echo "Proposal ID: $PROPOSAL_ID"

Voting Automation with Delegates

Once proposals exist, Claude Code can help manage voting through delegate accounts. This is particularly useful for protocols where you hold voting power across multiple wallets.

Delegate Voting Pattern

class GovernanceVoter {
  constructor(delegates, governorAddress) {
    this.delegates = delegates;
    this.governor = new ethers.Contract(governorAddress,GovernorABI,provider);
  }
  
  async castVote(proposalId, voteType) {
    // voteType: 0=Against, 1=For, 2=Abstain
    const results = await Promise.all(
      this.delegates.map(async (delegate) => {
        const wallet = new ethers.Wallet(delegate.privateKey, provider);
        const contract = this.governor.connect(wallet);
        const tx = await contract.castVote(proposalId, voteType);
        return tx.hash;
      })
    );
    return results;
  }
}

The key insight here is that Claude Code can maintain a secure configuration of delegate keys (never committing them to version control) and execute voting across all accounts with a single command.

Monitoring and Execution

The final piece of the governance workflow is monitoring proposal status and executing passed measures. Claude Code can continuously monitor chain state:

async function checkProposalState(proposalId) {
  const state = await governor.state(proposalId);
  const states = ['Pending', 'Active', 'Canceled', 'Defeated', 'Succeeded', 'Queued', 'Expired', 'Executed'];
  console.log(`Proposal ${proposalId}: ${states[state]}`);
  
  if (state === 4) { // Succeeded
    await queueForTimelock(proposalId);
  }
}

For continuous monitoring, set up a simple cron job that Claude Code can manage:

# Run every 5 minutes to check active proposals
*/5 * * * * cd /path/to/governance && node monitor-proposals.js >> /var/log/governance.log

Security Considerations

When automating governance with Claude Code, follow these security practices:

  1. Never commit private keys: Use environment variables or a secrets manager
  2. Multi-sig for execution: Configure your timelock to require multiple signatures
  3. Timelock verification: Always verify the timelock delay before execution
  4. Proposal simulation: Test calldata with eth_call before submitting

Actionable Summary

To implement a complete Compound governance workflow with Claude Code:

  1. Create a governance skill with file and bash tool access
  2. Define proposals in structured JSON configuration files
  3. Build submission scripts that interact with Governor contracts
  4. Implement delegate voting automation for multi-wallet governance
  5. Set up monitoring for proposal state transitions
  6. Always follow security best practices for key management

Claude Code transforms governance from a manual, error-prone process into a reliable, auditable workflow. By treating governance operations as code-configured actions, you gain repeatability and safety in protocol management.

Built by theluckystrike — More at zovo.one