web3-btt
npx skills add https://github.com/sablier-labs/agent-skills --skill web3-btt
Agent 安装分布
Skill 文档
Branching Tree Technique (BTT) Skill
Write bulloak tree specifications for smart contract tests.
Bundled References
| Reference | Content | When to Read |
|---|---|---|
./references/examples.md |
Complete tree and generated test examples | When learning BTT syntax |
./references/sablier-conventions.md |
Sablier-specific terminology and examples | When working in Sablier repos |
What is Bulloak?
Bulloak is a Solidity test generator that creates test scaffolds from .tree specification files. It offers a
structured approach to test case design that ensures comprehensive coverage of all possible scenarios and edge cases in
your smart contract tests.
Commands
To install Bulloak, if not found
cargo install bulloak
Generate test contract from a .tree file
bulloak scaffold -wf --skip-modifiers --format-descriptions <path/to/file.tree>
where:
--format-descriptionscapitalizes the first letter of the branch in the test contract and add a period at the end of it.--skip-modifiersskips the generation of modifiers. We do this because we put all the modifiers in a separateModifiers.solfile.
Check if the code in .t.sol file matches the specification in the .tree file
bulloak check --skip-modifiers <path/to/file.tree>
Tree Syntax
Structure
FunctionName_ContractName_Integration_Test
âââ condition1
â âââ outcome1
âââ condition2
âââ outcome2
Terminology
| Keyword | Purpose |
|---|---|
when |
Conditional branch (user input or timestamp) |
given |
Pre-condition contract state branch |
it |
Action/assertion (leaf node) |
whenandgivenbecome modifiers if they have nested branches.
Spec
- In case of single tree per file, the root should be just the function name followed by
_Integration_Concrete_Test. - In case of multiple trees in the same file, each root must be
Contract::function, using::as a separator, and all roots must share the same contract name (e.g.,Foo::hashPair,Foo::min). - bulloak expects you to use â and â characters to denote branches
- If a branch starts with either
whenorgiven, it is a condition.whenandgivenare interchangeable. - If a branch starts with
it, it is an action. Any child branch an action has is called an action description.
Examples
For examples, see ./references/examples.md.
Rules
- The test file must be placed in the
tests/integration/concrete/{function}directory. - The directory name must use
-format. For example, if the function name iscreateFlowStream, the corrresponding test tree and test file must be placed in thetests/integration/concrete/create-flow-streamdirectory. - The tree file name must be
{function}.tree. - The test file name must be
{function}.t.sol. - The root node of the spec and the Contract name must be
{FunctionName}_Integration_Concrete_Test.
Workflow
1. Create the Tree File
Location for tree file: tests/integration/concrete/{function-name}/{functionName}.tree
Note: Your repo’s agent will provide the exact directory structure.
2. Generate Test Scaffold
bulloak scaffold -wf --skip-modifiers --format-descriptions <path/to/file.tree>
This generates a .t.sol file.
3. Check Tree-Test Alignment
bulloak check --skip-modifiers <path/to/file.tree>
If it returns false, your repo agent will look into it and fix the issues.
Best Practices
1. Order Conditions Logically
Start with guard conditions that cause early reverts:
âââ when delegate call // First: delegation check
â âââ it should revert.
âââ when no delegate call
âââ given null // Second: existence check
â âââ it should revert.
âââ given not null
âââ when amount zero // Third: input validation
â âââ it should revert.
âââ when amount not zero
âââ ... // Finally: business logic
2. Use Consistent Terminology
Some examples below:
| Concept | Convention |
|---|---|
| Resource doesn’t exist | given null |
| Resource exists | given not null |
| Caller check | when caller {role} |
| Amount check | when amount {condition} |
Whenever possible, try to use less words and more concise language for the branches.
3. Group Related Conditions
âââ when withdrawal address not zero
âââ when withdrawal address not owner // Non-owner cases
â âââ when caller sender
â âââ when caller unknown
â âââ when caller recipient
âââ when withdrawal address owner // Owner cases
âââ ...
4. Detailed Leaf Nodes for Happy Path
For success cases, enumerate all side effects:
âââ it should make the withdrawal.
âââ it should reduce the entry balance by the withdrawn amount.
âââ it should reduce the aggregate amount by the withdrawn amount.
âââ it should update the entry state.
âââ it should update the timestamp.
âââ it should emit {Transfer}, {Withdraw} and {MetadataUpdate} events.
Put events in parenthesis: {EventName}.
5. Use proper indentation
Child branch symbols (â/â) must align with the tail of parent’s âââ or âââ (3 spaces, not 4):
âââ when withdrawal address not zero
âââ when withdrawal address not owner â Correct (3 spaces)
â âââ when caller sender
Running Bulloak
# Scaffold tests from tree
bulloak scaffold -wf --skip-modifiers --format-descriptions <path/to/file.tree>
# Check all trees in a directory
bulloak check --skip-modifiers tests/**/*.tree
Full Documentation
https://github.com/alexfertel/bulloak/blob/main/README.md
Example Invocations
Test this skill with these prompts:
- Basic tree: “Write a BTT tree for a
depositfunction that reverts when amount is zero and succeeds otherwise” - Complex tree: “Create a tree spec for
withdrawthat checks null stream, caller authorization, and amount validation” - Sablier-specific: “Write a BTT tree for
cancelin the Lockup protocol with proper stream state checks”