Skip to content

Commit fc6cbdf

Browse files
steinerkelvinclaude
andcommitted
docs: improve documentation and add Claude Code guidance
- Add CLAUDE.md with repository guidance for Claude Code assistant - Standardize shell code blocks to use 'sh' instead of 'bash' - Add spell checker words to VS Code settings - Simplify README project description for clarity - Add temporary files pattern to .gitignore 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent b421a44 commit fc6cbdf

File tree

6 files changed

+70
-28
lines changed

6 files changed

+70
-28
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Local files
2+
*.local.*
3+
14
# Temporary files
25
/tmp/
36

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
"coverage-gutters.coverageFileNames": ["target/cov.xml"],
1313
// Spell checker
1414
"cSpell.words": [
15+
"alice",
1516
"buildx",
1617
"devcontainers",
18+
"extrinsics",
1719
"irongut",
1820
"jwalton",
21+
"mainnet",
1922
"presign",
2023
"Swatinem",
2124
"wbuild"

CLAUDE.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code when working with this Substrate blockchain repository.
4+
5+
## References
6+
7+
- @README.md - Project overview, quick start, network setup
8+
- @CONTRIBUTING.md - Development setup (Nix), guidelines, testing
9+
- @docs/pallet-structure.md - Architecture and API design
10+
- @docs/xtask-manual.md - Development tooling guide
11+
12+
## Core Pallets
13+
14+
- **`torus0`**: Agent registration, staking, burn mechanisms
15+
- **`emission0`**: Token distribution with linear emission algorithm
16+
- **`governance`**: Proposals, voting, treasury, roles
17+
- **`permission0`**: Permission and access control
18+
19+
## Essential Commands
20+
21+
```sh
22+
nix develop # Enter development environment
23+
just # Run checks and tests (default)
24+
just check # Clippy linting only
25+
just test # Test suite only
26+
cargo xtask coverage # Test coverage report
27+
```
28+
29+
## Critical Safety Rules
30+
31+
- Never use `unwrap()`, `expect()`, or panicking operations in pallet code
32+
- Use `checked_div()` instead of `/` for arithmetic operations
33+
- Panics in runtime code will halt the chain
34+
- Use `FixedU128` for financial calculations

CONTRIBUTING.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,22 @@ The project uses Nix flakes to manage dependencies and ensure a consistent devel
1818

1919
1. Install Nix package manager by following the instructions at [nixos.org](https://nixos.org/download.html)
2020
2. Enable flakes by adding the following to your `~/.config/nix/nix.conf` or `/etc/nix/nix.conf`:
21-
```
21+
22+
```conf
2223
experimental-features = nix-command flakes
2324
```
25+
2426
3. Enter the development environment:
2527

26-
```bash
28+
```sh
2729
nix develop
2830
```
2931

3032
This will set up the correct Rust version, git, and precompiled binaries for dependencies like RocksDB and OpenSSL.
3133

3234
4. Build the project:
33-
```bash
35+
36+
```sh
3437
cargo build --release
3538
```
3639

@@ -92,23 +95,23 @@ For detailed guidance on creating migrations, refer to the [Substrate Storage Mi
9295

9396
1. Fork the repo and create a new branch for your feature or bugfix:
9497

95-
```bash
98+
```sh
9699
git checkout -b feature/your-feature-name
97100
```
98101

99102
2. Make your changes, following our code guidelines and testing requirements
100103

101104
3. Run tests and checks to ensure your changes don't break existing functionality:
102105

103-
```bash
106+
```sh
104107
cargo fmt
105108
cargo clippy
106109
cargo test
107110
```
108111

109112
4. Check code coverage to ensure sufficient test coverage:
110113

111-
```bash
114+
```sh
112115
cargo xtask coverage
113116
```
114117

@@ -125,7 +128,7 @@ Strong test coverage is a core value for our project. All pallets must maintain
125128
126129
Run the following command to generate a `Cobertura` xml file on `target/cov.xml` that can be used with the [Coverage Gutters](https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters) VSCode plugin to display which functions and branches are not covered by tests yet.
127130

128-
```bash
131+
```sh
129132
cargo xtask coverage
130133
```
131134

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44

55
![Docker Build](https://github.com/renlabs-dev/torus-substrate/actions/workflows/build-docker.yml/badge.svg)
66

7-
Torus is a self-assembling and evolving peer-to-peer blockchain organism, with a
8-
stake-driven network built in Rust with the Substrate framework. Torus powers an
9-
innovative ecosystem of agents and incentives, incorporating diverse
10-
technologies into its collective body.
7+
Torus is a self-assembling and evolving peer-to-peer organism with a
8+
stake-driven ecosystem of agents and incentives. It's core coordination system
9+
is a blockchain built on Substrate, implemented in this repository.
1110

1211
## Table of Contents
1312

@@ -74,7 +73,7 @@ The Torus node operates on two primary ports:
7473

7574
We have tools to simulate a network locally as well. The `cargo xtask run` command allows you to run a local network from scratch by setting up nodes with fresh spec files:
7675

77-
```bash
76+
```sh
7877
cargo xtask generate-spec gen-new --sudo <your Torus key> -o myspec.json
7978
cargo xtask run local --chain myspec.json --alice --node-validator true &
8079
cargo xtask run local --chain myspec.json --bob --node-validator true &
@@ -84,21 +83,21 @@ The `generate-spec` command has been expanded with subcommands that allow you to
8483

8584
1. Generate a new empty chain spec with custom parameters:
8685

87-
```bash
86+
```sh
8887
cargo xtask generate-spec gen-new --name "My Custom Chain" --sudo <your Torus key> -o myspec.json
8988
```
9089

9190
2. Generate a replica of the mainnet:
9291

93-
```bash
92+
```sh
9493
cargo xtask generate-spec gen-replica --sudo <your Torus key> -o myreplica.json
9594
```
9695

9796
You can also pass an `--api-url` flag with a WS endpoint to clone the state from.
9897

9998
Both commands take additional parameters to configure Aura, Grandpa and balances. For example:
10099

101-
```bash
100+
```sh
102101
cargo xtask generate-spec gen-new \
103102
--name "My Chain" \
104103
--sudo <your Torus key> \
@@ -110,7 +109,7 @@ cargo xtask generate-spec gen-new \
110109

111110
You can then run nodes with the generated specs:
112111

113-
```bash
112+
```sh
114113
cargo xtask run local --chain myspec.json --alice --node-validator true &
115114
cargo xtask run local --chain myspec.json --bob --node-validator true &
116115
```

docs/xtask-manual.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The `run` command launches Torus nodes with various configuration options. It of
2020

2121
The local mode starts a node using either a provided chain spec file or the default development configuration:
2222

23-
```bash
23+
```sh
2424
cargo xtask run local [OPTIONS]
2525
```
2626

@@ -38,7 +38,7 @@ The Alice and Bob accounts come with predefined keys and network configurations.
3838

3939
The replica mode creates and runs a node that replicates the mainnet state:
4040

41-
```bash
41+
```sh
4242
cargo xtask run replica [OPTIONS]
4343
```
4444

@@ -58,7 +58,7 @@ The `generate-spec` command creates chain specification files that define the in
5858

5959
The `gen-new` subcommand creates a fresh chain specification with customizable parameters:
6060

61-
```bash
61+
```sh
6262
cargo xtask generate-spec gen-new [OPTIONS] -o <OUTPUT_FILE>
6363
```
6464

@@ -73,7 +73,7 @@ Important options include:
7373

7474
For example, to create a new chain with custom authorities and initial balances:
7575

76-
```bash
76+
```sh
7777
cargo xtask generate-spec gen-new \
7878
--name "My Test Network" \
7979
--sudo 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY \
@@ -87,7 +87,7 @@ cargo xtask generate-spec gen-new \
8787

8888
The `gen-replica` subcommand creates a chain specification that replicates the current mainnet state:
8989

90-
```bash
90+
```sh
9191
cargo xtask generate-spec gen-replica [OPTIONS] -o <OUTPUT_FILE>
9292
```
9393

@@ -100,7 +100,7 @@ This command fetches the entire state from a running node and creates a chain sp
100100

101101
Example usage:
102102

103-
```bash
103+
```sh
104104
cargo xtask generate-spec gen-replica \
105105
--sudo 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY \
106106
--api-url "wss://my-custom-node.torus.network" \
@@ -125,7 +125,7 @@ The typical workflow is to first generate a chain spec file with desired propert
125125

126126
Here's an example of setting up a two-node local network:
127127

128-
```bash
128+
```sh
129129
# Generate a chain spec
130130
cargo xtask generate-spec gen-new --sudo 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY -o local-spec.json
131131

@@ -142,7 +142,7 @@ The nodes will automatically connect to each other and start producing blocks si
142142

143143
The `coverage` command generates code coverage reports for the Torus pallets:
144144

145-
```bash
145+
```sh
146146
cargo xtask coverage [--html]
147147
```
148148

@@ -158,7 +158,7 @@ The xtask tools use several techniques to simplify working with Torus. It provid
158158

159159
You can customize various node parameters to fit your specific needs:
160160

161-
```bash
161+
```sh
162162
cargo xtask run local [OPTIONS] --chain-spec my-spec.json \
163163
--node-name "Custom Node" \
164164
--node-key <KEY> \
@@ -168,13 +168,13 @@ cargo xtask run local [OPTIONS] --chain-spec my-spec.json \
168168

169169
For testing in isolation, you can prevent the node from connecting to other peers with the `--isolated` flag:
170170

171-
```bash
171+
```sh
172172
cargo xtask run local --chain-spec my-spec.json --isolated
173173
```
174174

175175
You can also specify custom bootnodes for your node to connect to:
176176

177-
```bash
177+
```sh
178178
cargo xtask run local --chain-spec my-spec.json \
179179
--bootnodes "/ip4/192.168.1.1/tcp/30333/p2p/<node-id>" \
180180
--bootnodes "/ip4/192.168.1.2/tcp/30333/p2p/<node-id>"
@@ -186,6 +186,6 @@ When working with xtask, you might encounter some common issues. If a node fails
186186

187187
For debugging purposes, you can examine the temporary node directories to check logs and configuration files. The path is printed when the node starts. You can also run a node without using xtask to get more detailed logs:
188188

189-
```bash
189+
```sh
190190
./target/release/torus-node -d /tmp/node-data --chain my-spec.json --validator
191191
```

0 commit comments

Comments
 (0)