catalog/repos/0xlayerghost--solidity-agent-kit.md

294 lines
12 KiB
Markdown
Raw Permalink Normal View History

2026-04-06 19:01:37 +08:00
# Solidity智能合约AI技能包
2026-04-06 15:47:33 +08:00
2026-04-06 19:01:37 +08:00
`Solidity` `智能合约` `AI编程助手` `DeFi安全` `Foundry` `EVM`
2026-04-06 15:47:33 +08:00
<div align="center">
# solidity-agent-kit
2026-04-06 19:01:37 +08:00
**经过实战检验的 Solidity 智能合约开发 AI 代理技能集**
2026-04-06 15:47:33 +08:00
2026-04-06 19:01:37 +08:00
*为你的编程代理装备专业级 Solidity 实践 —— 从编码规范到 DeFi 安全。*
2026-04-06 15:47:33 +08:00
<br/>
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat&logo=opensourceinitiative&logoColor=white)](https://opensource.org/licenses/MIT)
[![Solidity](https://img.shields.io/badge/Solidity-%5E0.8.20-363636?style=flat&logo=solidity&logoColor=white)](https://soliditylang.org)
[![Foundry](https://img.shields.io/badge/built%20with-Foundry-orange?style=flat&logo=ethereum&logoColor=white)](https://getfoundry.sh)
[![Skills](https://img.shields.io/badge/9%20skills-blueviolet?style=flat&logo=bookstack&logoColor=white)](https://skills.sh/0xlayerghost/solidity-agent-kit)
[![Agents](https://img.shields.io/badge/8%2B%20agents-informational?style=flat&logo=probot&logoColor=white)](#supported-agents)
<br/>
2026-04-06 19:01:37 +08:00
**EVM 兼容链**
2026-04-06 15:47:33 +08:00
[![Ethereum](https://img.shields.io/badge/Ethereum-3C3C3D?style=flat&logo=ethereum&logoColor=white)](https://ethereum.org)
[![Polygon](https://img.shields.io/badge/Polygon-8247E5?style=flat&logo=polygon&logoColor=white)](https://polygon.technology)
[![Arbitrum](https://img.shields.io/badge/Arbitrum-28A0F0?style=flat&logo=ethereum&logoColor=white)](https://arbitrum.io)
[![Optimism](https://img.shields.io/badge/Optimism-FF0420?style=flat&logo=optimism&logoColor=white)](https://optimism.io)
[![Base](https://img.shields.io/badge/Base-0052FF?style=flat&logo=coinbase&logoColor=white)](https://base.org)
[![Avalanche](https://img.shields.io/badge/Avalanche-E84142?style=flat&logo=avalanche&logoColor=white)](https://avax.network)
[![BNB Chain](https://img.shields.io/badge/BNB%20Chain-F0B90B?style=flat&logo=binance&logoColor=black)](https://bnbchain.org)
[![zkSync](https://img.shields.io/badge/zkSync-1E69FF?style=flat&logo=ethereum&logoColor=white)](https://zksync.io)
[![Linea](https://img.shields.io/badge/Linea-121212?style=flat&logo=consensys&logoColor=white)](https://linea.build)
</div>
---
2026-04-06 19:01:37 +08:00
## 什么是 solidity-agent-kit
2026-04-06 15:47:33 +08:00
2026-04-06 19:01:37 +08:00
`solidity-agent-kit` 是一套 **AI 代理技能集合**,为你的编程代理注入专业级 Solidity 开发知识。无需每次手写提示词,也不必寄希望于 AI 代理自行了解最佳实践 —— 一次安装,即可在所有项目中获得一致、经过实战验证的开发行为。
2026-04-06 15:47:33 +08:00
2026-04-06 19:01:37 +08:00
> 为你的 AI 编程代理装备经过实战检验的 Solidity 开发实践 —— 从编码规范到 DeFi 安全。
2026-04-06 15:47:33 +08:00
```
2026-04-06 19:01:37 +08:00
未使用 solidity-agent-kit 使用 solidity-agent-kit
───────────────────────── ─────────────────────────
AI 代理直接写代码... AI 代理调用 /solidity-coding
❌ 风格不一致 ✅ 强制 NatSpec、自定义错误
❌ 遗漏安全检查 ✅ 执行 /solidity-security 规则
❌ 无部署验证流程 ✅ 强制部署前检查清单
❌ 测试覆盖率低 ✅ 模糊测试、100% 分支覆盖
❌ 存在 DeFi 漏洞 ✅ 反闪电贷、反鲸鱼操控保护
2026-04-06 15:47:33 +08:00
```
---
2026-04-06 19:01:37 +08:00
## 目录
2026-04-06 15:47:33 +08:00
2026-04-06 19:01:37 +08:00
- [安装](#安装)
- [内置技能](#内置技能)
- [EVM 链支持](#evm-链支持)
- [架构说明](#架构说明)
- [支持的代理](#支持的代理)
- [技术栈](#技术栈)
- [项目结构](#项目结构)
- [许可证](#许可证)
2026-04-06 15:47:33 +08:00
---
2026-04-06 19:01:37 +08:00
## 安装
2026-04-06 15:47:33 +08:00
2026-04-06 19:01:37 +08:00
### 快速安装
2026-04-06 15:47:33 +08:00
```bash
2026-04-06 19:01:37 +08:00
# 交互模式 —— 选择要安装的技能
2026-04-06 15:47:33 +08:00
npx skills add 0xlayerghost/solidity-agent-kit
2026-04-06 19:01:37 +08:00
# 一次性安装所有技能(无需确认)
2026-04-06 15:47:33 +08:00
npx skills add 0xlayerghost/solidity-agent-kit -y
```
2026-04-06 19:01:37 +08:00
自动检测机器上所有 AI 代理并逐一安装。会创建 `.agents/``.claude/``.cursor/``.windsurf/` 目录 —— `.agents/` 存放实际文件,其余为符号链接。
2026-04-06 15:47:33 +08:00
2026-04-06 19:01:37 +08:00
### 指定代理安装
2026-04-06 15:47:33 +08:00
```bash
# Claude Code
npx skills add 0xlayerghost/solidity-agent-kit -y --agent claude-code
# Cursor
npx skills add 0xlayerghost/solidity-agent-kit -y --agent cursor
# Windsurf
npx skills add 0xlayerghost/solidity-agent-kit -y --agent windsurf
```
2026-04-06 19:01:37 +08:00
### 安装后配置
2026-04-06 15:47:33 +08:00
2026-04-06 19:01:37 +08:00
`CLAUDE.md` 模板复制到项目根目录,技能将自动触发 —— 无需手动输入 `/斜杠命令`
2026-04-06 15:47:33 +08:00
```bash
curl -sL https://raw.githubusercontent.com/0xlayerghost/solidity-agent-kit/main/CLAUDE.md.template -o CLAUDE.md
```
2026-04-06 19:01:37 +08:00
或手动将 [`CLAUDE.md.template`](./CLAUDE.md.template) 复制为项目根目录下的 `CLAUDE.md`
2026-04-06 15:47:33 +08:00
2026-04-06 19:01:37 +08:00
> `CLAUDE.md` 在每次 Claude Code 会话启动时自动加载,告诉代理**何时**自动调用各项技能。
2026-04-06 15:47:33 +08:00
2026-04-06 19:01:37 +08:00
添加到 `.gitignore` 保持仓库整洁:
2026-04-06 15:47:33 +08:00
```gitignore
2026-04-06 19:01:37 +08:00
# 代理技能(本地安装,不提交到仓库)
2026-04-06 15:47:33 +08:00
.agents/
.claude/
.cursor/
.trae/
.windsurf/
```
2026-04-06 19:01:37 +08:00
### 卸载
2026-04-06 15:47:33 +08:00
```bash
npx skills remove 0xlayerghost/solidity-agent-kit
```
---
2026-04-06 19:01:37 +08:00
## 内置技能
2026-04-06 15:47:33 +08:00
2026-04-06 19:01:37 +08:00
| # | 技能 | 触发时机 | 说明 | 链接 |
|---|------|----------|------|------|
| 1 | **solidity-coding** | 编写/编辑 `.sol` 文件 | Pragma 声明、命名规范、NatSpec 注释、自定义错误、反模式、OZ 导入 | [查看](https://skills.sh/0xlayerghost/solidity-agent-kit/solidity-coding) |
| 2 | **solidity-security** | 编写/编辑任意合约 | 私钥保护、访问控制、重入防护、Gas 限制 | [查看](https://skills.sh/0xlayerghost/solidity-agent-kit/solidity-security) |
| 3 | **solidity-testing** | 编写/编辑 `*.t.sol` | 测试布局、覆盖率 ≥90%、模糊测试、Foundry 不变量测试 | [查看](https://skills.sh/0xlayerghost/solidity-agent-kit/solidity-testing) |
| 4 | **solidity-deploy** | 编写 `*.s.sol` / 部署合约 | 部署前检查清单、环境变量、构造参数、部署后工作流 | [查看](https://skills.sh/0xlayerghost/solidity-agent-kit/solidity-deploy) |
| 5 | **solidity-debug** | 调试失败交易 | Cast 调用数据解码、回滚分析、Gas 诊断、追踪读取 | [查看](https://skills.sh/0xlayerghost/solidity-agent-kit/solidity-debug) |
| 6 | **solidity-audit** | 安全审计 | 手动审计检查清单存储、访问控制、算术运算、ERC 兼容性 | [查看](https://skills.sh/0xlayerghost/solidity-agent-kit/solidity-audit) |
| 7 | **defi-security** | DeFi 协议开发 | 反鲸鱼、反闪电贷、上线检查清单、紧急暂停、MEV 防护 | [查看](https://skills.sh/0xlayerghost/solidity-agent-kit/defi-security) |
| 8 | **git-workflow** | 提交/PR 前 | 约定式提交、分支命名、Solidity 项目 PR 模板 | [查看](https://skills.sh/0xlayerghost/solidity-agent-kit/git-workflow) |
| 9 | **claude-code-usage** | 每次 `/clear` 后 | 上下文恢复、子代理策略、计划模式、TodoWrite 使用模式 | [查看](https://skills.sh/0xlayerghost/solidity-agent-kit/claude-code-usage) |
2026-04-06 15:47:33 +08:00
---
2026-04-06 19:01:37 +08:00
## EVM 链支持
2026-04-06 15:47:33 +08:00
2026-04-06 19:01:37 +08:00
技能专为 **EVM 兼容链**设计,与 Foundry 多链工具链开箱即用:
2026-04-06 15:47:33 +08:00
```
2026-04-06 19:01:37 +08:00
主网 / L2 测试网
2026-04-06 15:47:33 +08:00
────────────── ──────────────
Ethereum (ETH) Sepolia
Polygon (MATIC) Mumbai
Arbitrum One Arbitrum Sepolia
Optimism OP Sepolia
Base Base Sepolia
Avalanche C-Chain Fuji
BNB Smart Chain BSC Testnet
zkSync Era zkSync Sepolia
Linea Linea Sepolia
```
2026-04-06 19:01:37 +08:00
部署和调试技能中涵盖了链特定的 `foundry.toml` 配置、RPC URL 管理及 `cast` 命令。
2026-04-06 15:47:33 +08:00
---
2026-04-06 19:01:37 +08:00
## 架构说明
2026-04-06 15:47:33 +08:00
```
2026-04-06 19:01:37 +08:00
你的项目
2026-04-06 15:47:33 +08:00
2026-04-06 19:01:37 +08:00
├── CLAUDE.md ◄── 技能自动触发规则
2026-04-06 15:47:33 +08:00
└── .agents/
└── 0xlayerghost/
└── solidity-agent-kit/
2026-04-06 19:01:37 +08:00
├── solidity-coding/ ──► 强制代码风格与 NatSpec
├── solidity-security/ ──► 访问控制与重入防护
├── solidity-testing/ ──► 模糊测试 + 不变量覆盖
├── solidity-deploy/ ──► 部署前后检查清单
├── solidity-debug/ ──► 基于 Cast 的交易分析
├── solidity-audit/ ──► 手动安全审计
├── defi-security/ ──► DeFi 特定攻击向量
├── git-workflow/ ──► 约定式提交与 PR
└── claude-code-usage/ ──► 代理上下文策略
AI 代理工作流:
2026-04-06 15:47:33 +08:00
─────────────────────────────────────────────────────────────
2026-04-06 19:01:37 +08:00
用户请求 ──► CLAUDE.md 检测任务类型
2026-04-06 15:47:33 +08:00
┌────────────┼────────────┐
▼ ▼ ▼
2026-04-06 19:01:37 +08:00
编写 .sol 测试 .t.sol 部署 .s.sol
2026-04-06 15:47:33 +08:00
│ │ │
/solidity-coding /solidity- /solidity-deploy
/solidity-security testing /defi-security
│ │ │
└────────────┴────────────┘
forge build
forge test
2026-04-06 19:01:37 +08:00
✅ 验证通过
2026-04-06 15:47:33 +08:00
```
---
2026-04-06 19:01:37 +08:00
## 支持的代理
2026-04-06 15:47:33 +08:00
2026-04-06 19:01:37 +08:00
| 代理 | 状态 | 备注 |
|------|------|------|
| **Claude Code** | ✅ 完整支持 | 最佳体验 —— CLAUDE.md 自动触发 |
| **Cursor** | ✅ 完整支持 | `.cursor/rules` 集成 |
| **Windsurf** | ✅ 完整支持 | `.windsurf/rules` 集成 |
| **Trae** | ✅ 支持 | `.trae` 集成 |
| **OpenCode** | ✅ 支持 | — |
| **Gemini CLI** | ✅ 支持 | — |
| **GitHub Copilot** | 🚧 部分支持 | 需手动调用 |
| **Codex CLI** | ✅ 支持 | — |
2026-04-06 15:47:33 +08:00
---
2026-04-06 19:01:37 +08:00
## 技术栈
2026-04-06 15:47:33 +08:00
2026-04-06 19:01:37 +08:00
| 工具 | 版本 | 用途 |
|------|------|------|
| **Solidity** | `^0.8.20` | 智能合约语言 |
| **Foundry** | 最新版 | 构建、测试、部署(`forge``cast``anvil` |
| **OpenZeppelin** | `4.9.x` | 安全合约标准ERC20/721/1155/Governor |
| **Slither** | 最新版 | 静态分析90+ 漏洞检测器) |
| **skills.sh** | 最新版 | 技能包管理与分发 |
2026-04-06 15:47:33 +08:00
---
2026-04-06 19:01:37 +08:00
## 项目结构
2026-04-06 15:47:33 +08:00
```
solidity-agent-kit/
2026-04-06 19:01:37 +08:00
├── CLAUDE.md.template ← 复制到项目根目录并重命名为 CLAUDE.md
2026-04-06 15:47:33 +08:00
├── skills/
2026-04-06 19:01:37 +08:00
│ ├── solidity-coding/ ← 编码规范与命名约定
2026-04-06 15:47:33 +08:00
│ │ └── SKILL.md
2026-04-06 19:01:37 +08:00
│ ├── solidity-security/ ← 安全最佳实践
2026-04-06 15:47:33 +08:00
│ │ └── SKILL.md
2026-04-06 19:01:37 +08:00
│ ├── solidity-testing/ ← 测试组织与覆盖率
2026-04-06 15:47:33 +08:00
│ │ └── SKILL.md
2026-04-06 19:01:37 +08:00
│ ├── solidity-deploy/ ← 部署工作流与检查
2026-04-06 15:47:33 +08:00
│ │ └── SKILL.md
2026-04-06 19:01:37 +08:00
│ ├── solidity-debug/ ← 链上交易调试
2026-04-06 15:47:33 +08:00
│ │ └── SKILL.md
2026-04-06 19:01:37 +08:00
│ ├── solidity-audit/ ← 手动安全审计检查清单
2026-04-06 15:47:33 +08:00
│ │ └── SKILL.md
2026-04-06 19:01:37 +08:00
│ ├── defi-security/ ← DeFi 特定攻击防护
2026-04-06 15:47:33 +08:00
│ │ └── SKILL.md
2026-04-06 19:01:37 +08:00
│ ├── git-workflow/ ← Solidity 项目 Git 规范
2026-04-06 15:47:33 +08:00
│ │ └── SKILL.md
2026-04-06 19:01:37 +08:00
│ └── claude-code-usage/ ← AI 代理上下文策略
2026-04-06 15:47:33 +08:00
│ └── SKILL.md
├── openai/
├── LICENSE
└── README.md
```
---
2026-04-06 19:01:37 +08:00
## 适用人群
2026-04-06 15:47:33 +08:00
2026-04-06 19:01:37 +08:00
- 使用 **Foundry**`forge``cast``anvil`)的 Solidity 开发者
- 构建 **DeFi 协议**、NFT 项目和 DAO 治理的团队
- 希望获得一致、安全输出的 **AI 编程代理**用户
- 使用 Slither + 手动检查清单进行**自动化审计**的安全工程师
- 在 **EVM 兼容链**上部署合约的任何开发者
2026-04-06 15:47:33 +08:00
---
2026-04-06 19:01:37 +08:00
## 许可证
2026-04-06 15:47:33 +08:00
2026-04-06 19:01:37 +08:00
MIT —— 详见 [LICENSE](./LICENSE)
2026-04-06 15:47:33 +08:00
---
<div align="center">
2026-04-06 19:01:37 +08:00
**由 [0xlayerghost](https://github.com/0xlayerghost) 构建**
2026-04-06 15:47:33 +08:00
2026-04-06 19:01:37 +08:00
*区块链与 Solidity 工程师*
2026-04-06 15:47:33 +08:00
[![GitHub](https://img.shields.io/badge/GitHub-0xlayerghost-181717?style=flat&logo=github)](https://github.com/0xlayerghost)
[![skills.sh](https://img.shields.io/badge/skills.sh-profile-blue?style=flat&logo=bookstack&logoColor=white)](https://skills.sh/0xlayerghost)
2026-04-06 19:01:37 +08:00
*如果这个项目帮助你交付了更安全的合约,请给一个 ⭐*
2026-04-06 15:47:33 +08:00
2026-04-06 19:01:37 +08:00
</div>