shell: fish functions -> ~/.local/bin executables + bash/zsh ports; manage ~/.agents

- 16 cross-shell utilities converted to sh/bash chezmoi executables:
  ai c2p cp-appid extract_agents fab gdc gh-sonr-org-migrate ghg-clone
  ghn gho git-summary launch_omp_livediff_overlay lc-elir mdcp mdp pj
  (ghg-clone not named ghg: unrelated cargo binary owns that name)
- cwd/history helpers stay per-shell: yy c cd clip-last + ghg/ghn/gho
  cd-wrappers in bash/functions/ and zsh/functions/, loaded by rc files
- fish keeps only shell-state functions; converted ones now hit PATH
- cp-appid ignore gating moved to .local/bin path
- dot_agents/skills: 82 skills materialized from dotstate storage so
  dot_claude skill symlinks resolve on fresh bootstrap; dotstate
  profile/symlinks.json released .agents/skills .bashrc .zshrc
This commit is contained in:
Prad Nukala committed 2026-08-10 15:15:06 -04:00
1 parent 6776366ce6
commit 6406208b35
637 files changed
+100297 -497

No files matched your search

@@ -0,0 +1,127 @@
---
name: solidity-foundry-development
description: Foundry development workflow for Solidity smart contracts. Use when building, testing, or deploying with Foundry (forge, cast, anvil). Covers project setup, foundry.toml configuration, testing patterns, fuzz testing, invariant testing, fork testing, cheatcodes, deployment scripts, and debugging. Triggers on tasks involving forge build, forge test, forge script, cast, anvil, or Foundry-based Solidity development.
license: MIT
metadata:
author: whackur (whackur@gmail.com)
version: "0.8.2"
---
# Foundry Development Guide
## When to Apply
Apply this skill when working on Solidity projects using the Foundry toolkit. This includes setting up new projects, writing unit and integration tests, performing fuzz and invariant testing, simulating mainnet conditions via fork testing, and managing deployments using Solidity scripts.
## Project Setup
Initialize a project with `forge init`. Manage dependencies using `forge install <author>/<repo>`. Configure `foundry.toml` for remappings, optimizer settings, and EVM versions. Use `remappings.txt` to simplify imports (e.g., `@openzeppelin/=lib/openzeppelin-contracts/contracts/`).
## Testing Best Practices
### Test Structure
Tests should inherit from `forge-std/Test.sol`. Use `setUp()` for state initialization.
- `test_Xxx`: Standard test case.
- `testFuzz_Xxx`: Fuzz test case.
- `testFail_Xxx`: Test expected to fail (prefer `vm.expectRevert`).
### Fuzz Testing
Foundry automatically provides random inputs for function arguments in `testFuzz` functions. Use `vm.assume()` to filter inputs or `bound(uint256 x, uint256 min, uint256 max)` to constrain values.
### Invariant Testing
Stateful fuzzing that ensures properties hold across multiple transactions.
- `targetContract(address)`: Define the contract to test.
- `handler`: Use a dedicated contract to manage complex call sequences and state transitions.
### Fork Testing
Simulate mainnet state by providing a RPC URL.
- `vm.createFork(url)`: Create a fork.
- `vm.selectFork(id)`: Switch to a fork.
- `vm.rollFork(blockNumber)`: Pin the fork to a specific block.
## Essential Cheatcodes
| Cheatcode | Description |
| ------------------------------------ | ------------------------------------------------------------- |
| `vm.prank(addr)` | Sets `msg.sender` for the next call. |
| `vm.startPrank(addr)` | Sets `msg.sender` for all subsequent calls until `stopPrank`. |
| `vm.deal(addr, amt)` | Sets the balance of an address. |
| `vm.expectRevert(bytes)` | Expects the next call to revert with a specific error. |
| `vm.expectEmit(bool,bool,bool,bool)` | Expects the next call to emit a specific event. |
| `vm.warp(timestamp)` | Sets the block timestamp. |
| `vm.roll(blockNumber)` | Sets the block number. |
| `vm.sign(pk, digest)` | Generates an ECDSA signature. |
| `vm.label(addr, name)` | Labels an address for better trace readability. |
| `vm.record()` | Starts recording all storage reads and writes. |
| `vm.getCode(path)` | Returns the creation bytecode of a contract. |
## Deployment Workflow
Use `forge script` for Solidity-based deployments.
- Dry-run: `forge script script/Deploy.s.sol --rpc-url $RPC_URL`
- Broadcast: `forge script script/Deploy.s.sol --rpc-url $RPC_URL --broadcast --verify`
- Use `--verify` with `--etherscan-api-key` for automatic source verification.
## Debugging
- Verbosity: `-v` (logs), `-vv` (traces for failed tests), `-vvv` (traces for all tests), `-vvvv` (setup traces), `-vvvvv` (full stack traces).
- `forge debug`: Interactive debugger for a specific transaction.
- `console.log`: Use `forge-std/console.sol` for print debugging.
## Configuration Profiles
Use profiles in `foundry.toml` to manage different build configurations.
```toml
[profile.via_ir]
via_ir = true
test = 'src'
out = 'via_ir-out'
[profile.deterministic]
block_number = 17722462
block_timestamp = 1689711647
bytecode_hash = 'none'
cbor_metadata = false
```
## Enhanced with MCP
When the `solidity-agent-toolkit` is available, leverage these tools in your Foundry workflow:
**Build & Test:**
- `compile_contract`: Compile contracts and get artifact output (ABI, bytecode, errors)
- `run_tests`: Execute the full Foundry test suite with verbosity control
- `run_single_test`: Target specific test functions for fast iteration
**Artifacts & Inspection:**
- `get_abi`: Extract ABI from compiled contracts
- `get_bytecode`: Get deployment or runtime bytecode
- `inspect_storage`: Inspect storage layout for optimization or debugging
- `gas_snapshot`: Generate and compare gas reports across test runs
- `estimate_gas`: Estimate gas for specific function calls
**Deployment:**
- `dry_run_deploy`: Simulate deployment to catch errors before broadcasting
- `check_deployment_status`: Verify deployment transaction status
**Security (Pre-commit):**
- `run_slither`: Static analysis before pushing code
- `run_aderyn`: Fast Rust-based vulnerability scan
- `match_vulnerability_patterns`: Quick pattern check on changed files
## References
Detailed command references and patterns can be found in [Foundry Cheatsheet](./references/foundry-cheatsheet.md).
@@ -0,0 +1,119 @@
# Foundry Cheatsheet
> **MCP Integration**: Many Forge commands have equivalent MCP tools (`compile_contract`, `run_tests`, `gas_snapshot`, `dry_run_deploy`). Use MCP tools for programmatic access within AI agent workflows.
## Forge Commands
- `forge build`: Compile the project.
- `forge test`: Run tests.
- `forge snapshot`: Generate gas snapshots.
- `forge script`: Run Solidity scripts.
- `forge verify-contract`: Verify contracts on Etherscan.
- `forge fmt`: Format Solidity files.
- `forge inspect`: Get contract metadata (bytecode, storage layout, etc.).
- `forge create`: Deploy a contract from the CLI.
- `forge debug`: Debug a single transaction.
## Cast Commands
- `cast call`: Perform a read-only call.
- `cast send`: Send a transaction.
- `cast estimate`: Estimate gas for a transaction.
- `cast abi-encode`: Encode arguments for a function.
- `cast abi-decode`: Decode return data.
- `cast sig`: Get the selector of a function signature.
- `cast storage`: Get the value of a storage slot.
- `cast block`: Get information about a block.
- `cast tx`: Get information about a transaction.
- `cast wallet`: Manage local wallets and keys.
## Anvil Commands
- `anvil`: Start a local Ethereum node.
- `--fork-url <URL>`: Fork a remote network.
- `--fork-block-number <BLOCK>`: Pin the fork to a block.
- `--port <PORT>`: Specify the port to listen on.
- `anvil_setBalance`: Set the balance of an account (via RPC).
## Common Cheatcode Patterns
### Identity & Funds
```solidity
vm.prank(alice);
contract.call(); // msg.sender is alice
vm.deal(alice, 10 ether); // alice now has 10 ETH
hoax(alice, 10 ether); // prank + deal
contract.call();
```
### Time & Blocks
```solidity
vm.warp(1641006000); // set block.timestamp
vm.roll(14000000); // set block.number
```
### State
```solidity
uint256 slot = vm.load(address(contract), bytes32(0));
vm.store(address(contract), bytes32(0), bytes32(uint256(1)));
uint256 id = vm.snapshot();
// ... do things ...
vm.revertTo(id);
```
### Assertions
```solidity
vm.expectRevert("Error message");
contract.fail();
vm.expectEmit(true, true, false, true);
emit MyEvent(1, 2, 3);
contract.emitEvent();
vm.expectCall(address(target), abi.encodeWithSelector(Target.func.selector));
contract.callTarget();
```
### Environment
```solidity
uint256 key = vm.envUint("PRIVATE_KEY");
address addr = vm.envAddress("CONTRACT_ADDR");
string memory s = vm.envString("API_KEY");
```
## Testing Patterns
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "forge-std/Test.sol";
import "../src/Counter.sol";
contract CounterTest is Test {
Counter public counter;
function setUp() public {
counter = new Counter();
counter.setNumber(0);
}
function test_Increment() public {
counter.increment();
assertEq(counter.number(), 1);
}
function testFuzz_SetNumber(uint256 x) public {
counter.setNumber(x);
assertEq(counter.number(), x);
}
}
```