Token导航 LogoToken导航TokenDH.com
开发执行命令github未标认证来源可访问许可证需确认审计通过

fp-rustFP Rust 命令行

Agent Skill

fp-rust 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

353

周安装

15

GitHub Stars

公开资料未说明

下载量

124
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:fp-rust(FP Rust 命令行)
来源仓库:https://github.com/mpurbo/purbo-skills
仓库路径:skills/fp-rust
安装命令:
npx skills add https://github.com/mpurbo/purbo-skills --skill fp-rust
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/mpurbo/purbo-skills --skill fp-rust

简介

fp-rust 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中围绕仓库状态和代码变更进行整理。
  • 可通过 npx skills add 命令从指定仓库安装并使用。
  • 安装前应确认权限范围、维护状态及是否执行联网或文件读写操作。
  • 建议参考原始 README 进一步了解具体功能和限制。

SKILL.md

Functional Rust Skill

Write Rust that is idiomatic, readable, and practical while maximizing FP principles. Rust is not Haskell — ownership IS the type-level effect system. Let FP emerge naturally from Rust's idioms: ownership, borrowing, iterators, enums, and traits.

For detailed patterns, code examples, library guidance, and rationale, read the companion reference: cat ${SKILL_PATH}/references/FP_RUST_GUIDELINES.md

Load the reference when you need: specific code examples for a pattern, library selection guidance (Appendix A/C), Clippy configuration (Appendix D), or the FP ↔ Rust concept map (Appendix B).


Core Architecture: Functional Core, Imperative Shell

Every program is a pure core surrounded by a thin imperative shell.

Core (in src/core/):

  • Never performs IO, reads clock, or logs
  • Receives data, returns data (or Result/Option as decisions)
  • Tested with pure unit tests — no mocks needed

Shell (in src/shell/ and src/main.rs):

  • Reads, writes, logs, calls core's pure functions
  • Interprets core's decisions into effects
  • Tested with integration tests

Litmus test: If core/ imports std::io or tokio, it belongs in shell/.

src/
├── main.rs              # Shell: wiring, IO, entry point
├── shell/               # Adapters: HTTP, DB, FS, CLI
├── core/                # Pure domain logic — NO std::fs, NO tokio
│   ├── types.rs         # ADTs, newtypes, domain models
│   ├── transform.rs     # Pure transformations
│   └── validate.rs      # Validation combinators
└── lib.rs               # Re-exports core

The Seven Principles

Apply these in order of priority when writing or reviewing Rust code:

1. Borrow > Clone > Mutate

  • Borrow (&T) for reads — zero cost, pure
  • Clone/Copy for transformations — create new values
  • Mutate (&mut T) only as last resort, encapsulated

Pass Copy types (i32, bool, f64, Duration) by value, not reference. Accept &str over String, &[T] over Vec<T> in parameters. Defer .to_string(), .collect() until the last possible moment.

2. Pure Functions

A function is pure if: same inputs → same output, no side effects. When a function needs something impure (time, random), inject it as a parameter:

// ❌ fn is_expired(token: &Token) -> bool { token.expires_at < SystemTime::now() }
// ✅ fn is_expired(token: &Token, now: SystemTime) -> bool { token.expires_at < now }

The signature tells the full story: no &mut self, no &dyn SomeService, no global state.

3. Algebraic Data Types

  • Use enum (sum types) to model possibilities — not flag fields or stringly-typed status
  • Use struct (product types) with private fields and constructors
  • Wrap primitives in newtypes: struct UserId(Uuid), struct Amount(Decimal)
  • Match exhaustively — avoid _ => that silently swallows future variants
  • Make illegal states unrepresentable via typestate pattern

4. Pipeline-Oriented Programming

Default to iterator chains (.iter().map().filter().collect()), not for loops. Use ? operator and .and_then() for Result chains (railway-oriented programming). Return impl Iterator<Item = T> over Vec<T> when possible — defer .collect().

Preference order:

.iter().map().filter().collect()  >  for + match (no mut)  >  for + mut accumulator

5. Errors Are Values

  • Domain errors as typed enums with thiserror
  • anyhow::Result in shell, typed errors in core
  • Never unwrap()/expect() in core — propagate with ?
  • Never panic! for expected conditions
  • Test both Ok and Err paths

6. Dependency Rejection Over Injection

Pass data in, get data out. Don't inject &dyn Repository — instead:

  • Shell fetches data from IO
  • Shell passes data to pure core function
  • Core returns decisions as values (including Vec<Command> for effects)
  • Shell interprets and executes effects

Trait abstraction only when genuinely multiple runtime backends (not "for testing").

7. Concurrency via Message Passing

  • Arc<T> (immutable sharing) over Arc<Mutex<T>> (mutable sharing)
  • Channels (mpsc, oneshot, broadcast) for coordination
  • rayon::par_iter() for CPU-bound parallel computation
  • Keep async in the shell; core stays sync and pure

Decision Checklist

Run through when writing or reviewing any function:

  1. IO/clock/randomness? → Shell. Inject data, not services.
  2. Can params be borrowed?&T, &str, &[T]. Copy types by value.
  3. Uses mut? → Replace with transform/fold/map. If needed, encapsulate.
  4. Uses unwrap()? → Only in shell/test/provably safe.
  5. Types tight enough?String → newtype? Option → separate type? bool → enum?
  6. Data pipeline?.iter() chains or .and_then(). Defer .collect().
  7. Dependency needed? → Reject it. Pass data, not services.
  8. Error handling complete? → Typed enums, exhaustive match, both paths tested.
  9. Documented?/// on public items, comments explain "why" not "what".

mut Concession Litmus Test

Before using mut in core code:

  1. Can I restructure to avoid it?
  2. Is the mutation encapsulated (invisible to caller)?
  3. Does the function remain deterministic from caller's perspective?

Acceptable concessions: performance-critical inner loops (with profiling evidence), builder patterns (produced value is immutable), complex fold readability, OnceCell/LazyLock for memoization, tracing for diagnostics only.


Key Pattern: fn(mut self) -> Self

This is NOT impure mutation — it's a value-to-value transform where Rust reuses memory. The caller passes ownership in and gets a new value out:

fn with_discount(mut order: Order, pct: f64) -> Order {
    order.total *= 1.0 - pct;
    order
}

Don't clone the world just to "look functional."


Crate Stack (Always Include)

[dependencies]
itertools = "0.14"       # Extended pipeline combinators
tap = "1"                # .pipe() and .tap() for pipeline readability
derive_more = { version = "1", features = ["full"] }  # Newtype ergonomics
thiserror = "2"          # Domain error enums
serde = { version = "1", features = ["derive"] }
rust_decimal = "1"       # Financial math (no floats)
anyhow = "1"             # Shell error handling
tokio = { version = "1", features = ["full"] }  # Shell async runtime
tracing = "0.1"          # Structured logging

For library evaluation, conditional crates (frunk, imbl, rayon, proptest), Clippy configuration, and the full FP ↔ Rust concept map, consult the reference document.


When Reviewing Code

Flag these patterns and suggest FP alternatives:

SmellSuggest
let mut for accumulation.fold() or .map().collect()
for loop pushing into VecIterator pipeline
&dyn Trait in core for testabilityDependency rejection
unwrap() in core/library code? or explicit error handling
String/bool for domain statesEnum (sum type) or newtype
Arc<Mutex<T>>Channels or Arc<T> immutable snapshot
IO in core functionsMove to shell, pass data in
_ => catch-all in matchExhaustive match with explicit variants
Nested if-let for Option/Result.map(), .and_then(), ? pipeline
.clone() to satisfy borrow checkerRestructure lifetimes, or use &T

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

33%
按下载量换算41

Claude

30.52%
按下载量换算38

Cursor

18.37%
按下载量换算23

Gemini CLI

8.34%
按下载量换算10

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/mpurbo/purbo-skills --skill fp-rust 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills