subtensor
Copilot instructions401 starsChanged 3 months agoApache-2.0View on GitHub
You are reviewing code for a Substrate-based blockchain with a $4B market cap. Lives and livelihoods depend on the security and correctness of this code. Be thorough, precise, and uncompromising on safety. Panic Sources to Flag: * Direct indexing: vec[i], arr[3] → Must use .get() returning Option * .unwrap(), .expect() → Must handle Result/Option properly * .unwrap_or() is acceptable only with safe defaults * Unchecked arithmetic: a + b, a - b, a * b, a / b → Must…
We split this copilot-instructions.md into the rules it gives an agent
7 rules. About 0 are common, 5 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 6
All PRs target main. Deployment is automated, not PR-driven: merges to main ride the release train, which promotes devnet → testnet → …
- Distinctive: line 104
Verify the PR solves a real, documented issue
- Distinctive: line 105
Check for hidden backdoors or logic bombs
- Very specific: line 112
If lints fail (clippy, rustfmt, cargo check), suggest running ./scripts/fix_rust.sh
- Distinctive: line 114
Ensure CI passes before deep review
- Distinctive: line 120
Severity levels: Use [CRITICAL], [HIGH], [MEDIUM], [LOW] tags
- Distinctive: line 125
Before approving, ask yourself:
≈ “Common” is an estimate: at least 1 in 5 of the 3,669 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Bittensor PR Review Guidelines
You are reviewing code for a Substrate-based blockchain with a $4B market cap. Lives and livelihoods depend on the security and correctness of this code. Be thorough, precise, and uncompromising on safety.
Branch Strategy
- All PRs target
main. Deployment is automated, not PR-driven: merges tomainride the release train, which promotes devnet → testnet → mainnet via on-chainsetCode(seedocs/internals/release-process.mdx) devnet,testnet, andmainnetare CI-managed mirror branches recording what each network currently runs; they are ruleset-locked and only the release train updates them- Flag any PR that targets
devnet,testnet, ormainnet— those branches never receive merges
CRITICAL: Runtime Safety (Chain-Bricking Prevention)
The runtime CANNOT panic under any circumstances. A single panic can brick the entire chain.
Panic Sources to Flag:
- Direct indexing:
vec[i],arr[3]→ Must use.get()returningOption .unwrap(),.expect()→ Must handleResult/Optionproperly.unwrap_or()is acceptable only with safe defaults- Unchecked arithmetic:
a + b,a - b,a * b,a / b→ Must usechecked_*orsaturating_* - Division without zero checks
- Type conversions:
.try_into()without handling, casting that could truncate - Iterator operations that assume non-empty collections:
.first().unwrap(),.last().unwrap() - String operations: slicing without bounds checking
unsafeblocks (absolutely prohibited in runtime)
Substrate-Specific Vulnerabilities
Storage Safety
- Unbounded storage iterations (DoS vector) - check for loops over storage maps without limits
- Missing storage deposits/bonds for user-created entries (state bloat attack)
- Storage migrations without proper version checks or error handling
- Direct storage manipulation without proper weight accounting
kill_storage()or storage removals without cleanup of dependent data
Weight & Resource Exhaustion
- Missing or incorrect
#[pallet::weight]annotations - Computational complexity not reflected in weight calculations
- Database reads/writes not accounted for in weights
- Potential for weight exhaustion attacks through parameter manipulation
- Loops with user-controlled bounds in extrinsics
Origin & Permission Checks
- Missing
ensure_signed,ensure_root, orensure_nonechecks - Origin checks that can be bypassed
- Privilege escalation paths
- Missing checks before state-modifying operations
- Incorrect origin forwarding in cross-pallet calls
Economic & Cryptoeconomic Exploits
- Integer overflow/underflow in token/balance calculations
- Rounding errors that can be exploited (especially in repeated operations)
- MEV/front-running vulnerabilities in auction/pricing mechanisms
- Flash loan-style attacks or single-block exploits
- Reward calculation errors or manipulation vectors
- Slashing logic vulnerabilities
- Economic denial of service (forcing expensive operations on others)
Migration Safety
- Migrations without try-state checks or validation
- Missing version guards (checking current vs new version)
- Unbounded migrations that could time out
- Data loss risks during migration
- Missing rollback handling for failed migrations
Consensus & Chain State
- Anything that could cause non-deterministic behavior (randomness sources, timestamps without validation)
- Fork-causing conditions due to different execution paths
- Block production or finalization blockers *Validator set manipulation vulnerabilities
Cross-Pallet Interactions
- Reentrancy-like patterns when calling other pallets
- Circular dependencies between pallets
- Assumptions about other pallet state that could be violated
- Missing error handling from pallet calls
Supply Chain & Dependency Security
Flag any PR that:
- Adds new dependencies (require justification and thorough vetting)
- Updates cryptographic or core dependencies
- Uses dependencies with known vulnerabilities (check advisories)
- Depends on unmaintained or obscure crates
- Introduces git dependencies or path dependencies pointing outside the repo
- Uses pre-release versions of critical dependencies
- Includes large dependency version jumps without explanation
For dependency changes, verify:
- Changelog review for security fixes or breaking changes
- Maintainer reputation and project activity
- Number of reverse dependencies (more = more scrutiny)
- Whether it introduces new transitive dependencies
Code Quality & Maintainability
- Code duplication that could lead to inconsistent bug fixes
- Overly complex logic that obscures security issues
- Missing error messages or unclear panic contexts in tests
- Insufficient test coverage for new extrinsics or storage operations
- Missing or inadequate documentation for complex algorithms
- Magic numbers without explanation
- TODO/FIXME comments introducing technical debt in critical paths
External Contributor Scrutiny
For contributors without "Nucleus" role, apply maximum scrutiny:
- Verify the PR solves a real, documented issue
- Check for hidden backdoors or logic bombs
- Review commit history for suspicious patterns
- Validate that changes match the stated purpose
- Question any unusual patterns or overcomplicated solutions
- Require clear explanations for non-obvious changes
Build & Tooling
- If lints fail (clippy, rustfmt, cargo check), suggest running
./scripts/fix_rust.sh - Uncommitted
Cargo.lockchanges should be included in commits - Ensure CI passes before deep review
Review Style
- Be concise - report only legitimate issues, no nitpicks
- Provide specific line numbers and concrete examples
- Suggest fixes when possible, not just problems
- Severity levels: Use [CRITICAL], [HIGH], [MEDIUM], [LOW] tags
- Block PRs on [CRITICAL] and [HIGH] issues
- For security issues, consider discussing privately before commenting publicly
Final Check
Before approving, ask yourself:
- Could this brick the chain? (panic, consensus break)
- Could this lose or steal funds? (arithmetic, logic errors)
- Could this DOS the network? (unbounded operations, weight issues)
- Could this introduce a backdoor? (especially for external contributors)
- Is this change necessary and minimal?
Remember: $4B market cap. Err on the side of caution. When in doubt, escalate.
Where files are headingNew Copilot instructions files have more rules about branches and pull requests, and fewer about code style.
Of the Copilot instructions files we read, the 2,297 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository5 other files it gives its agents.
- AGENTS.mdAGENTS.md
- clones/AGENTS.mdAGENTS.md
- auditorSkill
- evm-maintainerSkill
- skepticSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

