com um clique
doc
Document code in this repository.
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Menu
Document code in this repository.
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Baseado na classificação ocupacional SOC
Show what changed in leanSpec between devnet versions or HEAD
Run unit tests with coverage
Common developer workflows, commands, and troubleshooting for leanSpec
Read-only, multi-agent audit of the leanSpec codebase. Fans out the py-architect, consensus-researcher, code-tester, and doc-writer agents across the source tree to find dead code, over-abstraction, stdlib simplifications, test gaps, safety/security defects, and documentation rot, then synthesizes a precise, prioritized AUDIT_REPORT.md. Never modifies code.
Run leanSpec fixtures against a client implementation
Run all code quality checks
| name | doc |
| description | Document code in this repository. |
Write or refine documentation for leanSpec code.
The atomic style rules live in .claude/rules/documentation.md — defer to that file.
This skill defines what to document, how to scope the work, and shows a gold-standard exemplar.
Determine what to document from the argument passed to /doc:
git diff and git diff --cached to identify scope.
Do not touch unchanged code.When an argument is provided, document the target fully — not just uncommitted changes. The argument overrides the diff-only restriction.
When a header doc grows past one overview line, organize the detail under these section names:
Never title a section "Why ..." (for example "# Why the finalized slot is the cutoff"). That phrasing reads as AI filler. State the rationale as plain prose, the way an engineer would explain it to a colleague.
Test docstrings stay short. A one-line summary is usually enough. Education goes inline in structured blocks:
Invariant: <rule the test enforces>
Fixture state: <concrete numbers>
Mutation: <what we change and why>
<ASCII diagram of before/after>
Never write essay-style prose blocks in test docstrings.
Tests under tests/consensus/ follow one fixed skeleton so any vector reads the same way.
The full standard lives in .claude/rules/documentation.md under "Consensus test-vector docstrings".
The module-level file header is exactly one line.
The body carries no inline comments — the docstring is the single source of truth.
The skeleton is a one-line summary, then Given, When, Then. One atomic fact per bullet, fixed notation for blocks, validators, votes, and the chain.
def test_justified_divergence_self_heals_in_next_block(
fork_choice_test: ForkChoiceTestFiller,
) -> None:
"""
A block adopts the votes that justify a slot from a fork it did not extend.
Given
-----
- 4 validators; a slot needs 3 votes (2/3) to be justified.
- the chain:
genesis
- common(1)
- block_2(2) -> block_3(3)
- fork_4(4)
- block_3 includes V0's vote for block_2.
- fork_4 includes V1, V2, V3's votes for common.
- fork_4 reaches 3 votes, so it justifies slot 1.
- block_3 has only 1 vote, so it justifies nothing.
- the views diverge: node = slot 1, head chain = slot 0.
When
----
- block_5 is built on block_3, carrying no votes of its own.
Then
----
- block_5 pulls the slot-1 votes from the pool and includes them.
- the head chain justifies slot 1, matching the node.
- finalized stays at slot 0.
"""
Reference exemplar: tests/consensus/lstar/fork_choice/test_attestation_source_divergence.py.
These are the failure modes most likely to slip into leanSpec PRs:
.claude/rules/documentation.md rule 2.The target style for a well-documented Python function in this project. Note the tight one-sentence-per-line header, the plain-prose rationale, the phase-labeled body, and the ASCII layout diagram.
def encode_bitlist(bits: Sequence[Boolean]) -> bytes:
"""
Encode a variable-length bitlist to SSZ bytes.
# Overview
Data bits are packed little-endian within each byte.
A single 1 bit is placed immediately after the last data bit.
The trailing bit lets the decoder recover the original count.
SSZ encodes bitlists as raw bytes with no length prefix.
Without that trailing bit, [1, 0] and [1, 0, 0, 0, 0, 0, 0, 0] would share the byte 0x01.
A trailing 1 bit is the smallest sentinel that disambiguates them.
# Layout
bits = [1, 0, 1] -> byte 0: 0 0 0 0 [1] 1 0 1 (delimiter at bit 3)
bits = [1] * 8 -> byte 0: 1 1 1 1 1 1 1 1
byte 1: 0 0 0 0 0 0 0 [1] (delimiter spills)
Args:
bits: The variable-length bit data.
Returns:
SSZ-encoded bytes containing the data bits and the delimiter.
"""
# Phase 1: handle the empty case.
#
# No data bits means the encoding is just the delimiter.
num_bits = len(bits)
if num_bits == 0:
return b"\x01"
# Phase 2: pack data bits little-endian into a byte array.
#
# Bit i of the input lands in byte i // 8 at position i % 8.
byte_len = (num_bits + 7) // 8
byte_array = bytearray(byte_len)
for i, bit in enumerate(bits):
if bit:
byte_array[i // 8] |= 1 << (i % 8)
# Phase 3: place the delimiter immediately after the last data bit.
#
# When the bit count is a multiple of 8, the delimiter has no room
# in the existing array and spills into a fresh trailing byte.
if num_bits % 8 == 0:
return bytes(byte_array) + b"\x01"
byte_array[num_bits // 8] |= 1 << (num_bits % 8)
return bytes(byte_array)
Match this density of structure, brevity of lines, and use of concrete numbers and diagrams.
Before finishing a documentation pass, verify: