moonbit-bits-patterns
CommunityParse and validate bit-packed fields in BytesView
Authorpeter-jerry-ye
Version1.0.0
Installs0
System Documentation
What problem does it solve?
This skill addresses the challenge of extracting and validating bit-level fields from BytesView slices, enabling precise interpretation of packed data without manual bit-twiddling.
Core Features & Use Cases
- Explicit bit-width patterns: Use patterns with be/le suffixes to describe exact field sizes and endianness.
- Field binding and guards: Bind fields to locals, ignore unused bits, and implement validation guards.
- Compositional parsing: Slice Bytes to BytesView and chain parsers, returning (field, rest) for multi-step decoding of protocols or file formats.
- Use Case: Decode a packet header where [u1be(flag), u3be(type), u4be(code), ..] determine routing or validation.
Quick Start
Create a BytesView with a slice of the payload and pattern-match it using the syntax described above, e.g., match bytes[0:1] with [u1be(flag), u7be(..rest)] to extract a flag.
Dependency Matrix
Required Modules
None requiredComponents
references
💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: moonbit-bits-patterns Download link: https://github.com/peter-jerry-ye/skills/archive/main.zip#moonbit-bits-patterns Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.