[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6XASD9ZZ1GGAZEFMFS59T4V":3,"skill-same:01M6XASD9ZZ1GGAZEFMFS59T4V":107},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":49,"commitSha":50,"skillDirectory":51,"forksCount":13,"repositoryHtmlUrl":52,"repositoryHomepageUrl":6,"ownerHtmlUrl":53,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":54,"install":55,"resources":68},"01M6XASD9ZZ1GGAZEFMFS59T4V","rust-best-practices",null,"Guide for writing idiomatic Rust code based on Apollo GraphQL's best practices handbook. Use this skill when: (1) writing new Rust code or functions, (2) reviewing or refactoring existing Rust code, (3) deciding between borrowing vs cloning or ownership patterns, (4) implementing error handling with Result types, (5) optimizing Rust code for performance, (6) writing tests or documentation for Rust projects.","novolei\u002Fif2Ai","novolei","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F3054688?v=4","01M6XAS8G7GEDH7PDHJK640321","01M6XAS8MSXWZQPY2C3ZQKGPK2",0,"MIT","https:\u002F\u002Fgithub.com\u002Fnovolei\u002Fif2Ai\u002Fblob\u002Ffeature\u002Fconsolidate-codebase\u002F.cursor\u002Fskills\u002Frust-best-practices\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"rust","rust best practices","best practices","read","apollo graphql","when","result","implementing","types","error","cloning","edit","write","writing","projects","refactoring","Bash","code","documentation","performance","2026-11-10 10:12:30",false,"---\nname: rust-best-practices\ndescription: >\n  Guide for writing idiomatic Rust code based on Apollo GraphQL's best practices handbook. Use this skill when:\n  (1) writing new Rust code or functions,\n  (2) reviewing or refactoring existing Rust code,\n  (3) deciding between borrowing vs cloning or ownership patterns,\n  (4) implementing error handling with Result types,\n  (5) optimizing Rust code for performance,\n  (6) writing tests or documentation for Rust projects.\nlicense: MIT\ncompatibility: Rust 1.70+, Cargo\nmetadata:\n  author: apollographql\n  version: \"1.1.0\"\nallowed-tools: Bash(cargo:*) Bash(rustc:*) Bash(rustfmt:*) Bash(clippy:*) Read Write Edit Glob Grep\n---\n\n# Rust Best Practices\n\nApply these guidelines when writing or reviewing Rust code. Based on Apollo GraphQL's [Rust Best Practices Handbook](https:\u002F\u002Fgithub.com\u002Fapollographql\u002Frust-best-practices).\n\n## Best Practices Reference\n\n按需阅读 **1～2 个** chapter 文件即可；**不要**在同一 turn 内并行读完所有章节（token 浪费）。按任务选读：\n\n| 任务 | 优先读 |\n|------|--------|\n| 借用\u002Fclone\u002F迭代器 | chapter_01 |\n| clippy \u002F lint 配置 | chapter_02 |\n| 性能 \u002F 克隆 \u002F 堆栈 | chapter_03 |\n| Result \u002F thiserror \u002F anyhow | chapter_04 |\n| 测试命名 \u002F snapshot | chapter_05 |\n| 泛型 \u002F dyn Trait | chapter_06 |\n| typestate | chapter_07 |\n| 注释 vs rustdoc | chapter_08 |\n| Send\u002FSync \u002F 指针 | chapter_09 |\n\n完整章节索引（仅在需要深入时打开对应文件）：\n\n- [Chapter 1 - Coding Styles and Idioms](references\u002Fchapter_01.md): Borrowing vs cloning, Copy trait, Option\u002FResult handling, iterators, comments\n- [Chapter 2 - Clippy and Linting](references\u002Fchapter_02.md): Clippy configuration, important lints, workspace lint setup\n- [Chapter 3 - Performance Mindset](references\u002Fchapter_03.md): Profiling, avoiding redundant clones, stack vs heap, zero-cost abstractions\n- [Chapter 4 - Error Handling](references\u002Fchapter_04.md): Result vs panic, thiserror vs anyhow, error hierarchies\n- [Chapter 5 - Automated Testing](references\u002Fchapter_05.md): Test naming, one assertion per test, snapshot testing\n- [Chapter 6 - Generics and Dispatch](references\u002Fchapter_06.md): Static vs dynamic dispatch, trait objects\n- [Chapter 7 - Type State Pattern](references\u002Fchapter_07.md): Compile-time state safety, when to use it\n- [Chapter 8 - Comments vs Documentation](references\u002Fchapter_08.md): When to comment, doc comments, rustdoc\n- [Chapter 9 - Understanding Pointers](references\u002Fchapter_09.md): Thread safety, Send\u002FSync, pointer types\n\n## Quick Reference\n\n### Borrowing & Ownership\n- Prefer `&T` over `.clone()` unless ownership transfer is required\n- Use `&str` over `String`, `&[T]` over `Vec\u003CT>` in function parameters\n- Small `Copy` types (≤24 bytes) can be passed by value\n- Use `Cow\u003C'_, T>` when ownership is ambiguous\n\n### Error Handling\n- Return `Result\u003CT, E>` for fallible operations; avoid `panic!` in production\n- Never use `unwrap()`\u002F`expect()` outside tests\n- Use `thiserror` for library errors, `anyhow` for binaries only\n- Prefer `?` operator over match chains for error propagation\n\n### Performance\n- Always benchmark with `--release` flag\n- Run `cargo clippy -- -D clippy::perf` for performance hints\n- Avoid cloning in loops; use `.iter()` instead of `.into_iter()` for Copy types\n- Prefer iterators over manual loops; avoid intermediate `.collect()` calls\n\n### Linting\nRun regularly: `cargo clippy --all-targets --all-features --locked -- -D warnings`\n\nKey lints to watch:\n- `redundant_clone` - unnecessary cloning\n- `large_enum_variant` - oversized variants (consider boxing)\n- `needless_collect` - premature collection\n\nUse `#[expect(clippy::lint)]` over `#[allow(...)]` with justification comment.\n\n### Testing\n- Name tests descriptively: `process_should_return_error_when_input_empty()`\n- One assertion per test when possible\n- Use doc tests (`\u002F\u002F\u002F`) for public API examples\n- Consider `cargo insta` for snapshot testing generated output\n\n### Generics & Dispatch\n- Prefer generics (static dispatch) for performance-critical code\n- Use `dyn Trait` only when heterogeneous collections are needed\n- Box at API boundaries, not internally\n\n### Type State Pattern\nEncode valid states in the type system to catch invalid operations at compile time:\n```rust\nstruct Connection\u003CState> { \u002F* ... *\u002F _state: PhantomData\u003CState> }\nstruct Disconnected;\nstruct Connected;\n\nimpl Connection\u003CConnected> {\n    fn send(&self, data: &[u8]) { \u002F* only connected can send *\u002F }\n}\n```\n\n### Documentation\n- `\u002F\u002F` comments explain *why* (safety, workarounds, design rationale)\n- `\u002F\u002F\u002F` doc comments explain *what* and *how* for public APIs\n- Every `TODO` needs a linked issue: `\u002F\u002F TODO(#42): ...`\n- Enable `#![deny(missing_docs)]` for libraries\n","# Rust Best Practices\n\nApply these guidelines when writing or reviewing Rust code. Based on Apollo GraphQL's [Rust Best Practices Handbook](https:\u002F\u002Fgithub.com\u002Fapollographql\u002Frust-best-practices).\n\n## Best Practices Reference\n\n按需阅读 **1～2 个** chapter 文件即可；**不要**在同一 turn 内并行读完所有章节（token 浪费）。按任务选读：\n\n| 任务 | 优先读 |\n|------|--------|\n| 借用\u002Fclone\u002F迭代器 | chapter_01 |\n| clippy \u002F lint 配置 | chapter_02 |\n| 性能 \u002F 克隆 \u002F 堆栈 | chapter_03 |\n| Result \u002F thiserror \u002F anyhow | chapter_04 |\n| 测试命名 \u002F snapshot | chapter_05 |\n| 泛型 \u002F dyn Trait | chapter_06 |\n| typestate | chapter_07 |\n| 注释 vs rustdoc | chapter_08 |\n| Send\u002FSync \u002F 指针 | chapter_09 |\n\n完整章节索引（仅在需要深入时打开对应文件）：\n\n- [Chapter 1 - Coding Styles and Idioms](references\u002Fchapter_01.md): Borrowing vs cloning, Copy trait, Option\u002FResult handling, iterators, comments\n- [Chapter 2 - Clippy and Linting](references\u002Fchapter_02.md): Clippy configuration, important lints, workspace lint setup\n- [Chapter 3 - Performance Mindset](references\u002Fchapter_03.md): Profiling, avoiding redundant clones, stack vs heap, zero-cost abstractions\n- [Chapter 4 - Error Handling](references\u002Fchapter_04.md): Result vs panic, thiserror vs anyhow, error hierarchies\n- [Chapter 5 - Automated Testing](references\u002Fchapter_05.md): Test naming, one assertion per test, snapshot testing\n- [Chapter 6 - Generics and Dispatch](references\u002Fchapter_06.md): Static vs dynamic dispatch, trait objects\n- [Chapter 7 - Type State Pattern](references\u002Fchapter_07.md): Compile-time state safety, when to use it\n- [Chapter 8 - Comments vs Documentation](references\u002Fchapter_08.md): When to comment, doc comments, rustdoc\n- [Chapter 9 - Understanding Pointers](references\u002Fchapter_09.md): Thread safety, Send\u002FSync, pointer types\n\n## Quick Reference\n\n### Borrowing & Ownership\n- Prefer `&T` over `.clone()` unless ownership transfer is required\n- Use `&str` over `String`, `&[T]` over `Vec\u003CT>` in function parameters\n- Small `Copy` types (≤24 bytes) can be passed by value\n- Use `Cow\u003C'_, T>` when ownership is ambiguous\n\n### Error Handling\n- Return `Result\u003CT, E>` for fallible operations; avoid `panic!` in production\n- Never use `unwrap()`\u002F`expect()` outside tests\n- Use `thiserror` for library errors, `anyhow` for binaries only\n- Prefer `?` operator over match chains for error propagation\n\n### Performance\n- Always benchmark with `--release` flag\n- Run `cargo clippy -- -D clippy::perf` for performance hints\n- Avoid cloning in loops; use `.iter()` instead of `.into_iter()` for Copy types\n- Prefer iterators over manual loops; avoid intermediate `.collect()` calls\n\n### Linting\nRun regularly: `cargo clippy --all-targets --all-features --locked -- -D warnings`\n\nKey lints to watch:\n- `redundant_clone` - unnecessary cloning\n- `large_enum_variant` - oversized variants (consider boxing)\n- `needless_collect` - premature collection\n\nUse `#[expect(clippy::lint)]` over `#[allow(...)]` with justification comment.\n\n### Testing\n- Name tests descriptively: `process_should_return_error_when_input_empty()`\n- One assertion per test when possible\n- Use doc tests (`\u002F\u002F\u002F`) for public API examples\n- Consider `cargo insta` for snapshot testing generated output\n\n### Generics & Dispatch\n- Prefer generics (static dispatch) for performance-critical code\n- Use `dyn Trait` only when heterogeneous collections are needed\n- Box at API boundaries, not internally\n\n### Type State Pattern\nEncode valid states in the type system to catch invalid operations at compile time:\n```rust\nstruct Connection\u003CState> { \u002F* ... *\u002F _state: PhantomData\u003CState> }\nstruct Disconnected;\nstruct Connected;\n\nimpl Connection\u003CConnected> {\n    fn send(&self, data: &[u8]) { \u002F* only connected can send *\u002F }\n}\n```\n\n### Documentation\n- `\u002F\u002F` comments explain *why* (safety, workarounds, design rationale)\n- `\u002F\u002F\u002F` doc comments explain *what* and *how* for public APIs\n- Every `TODO` needs a linked issue: `\u002F\u002F TODO(#42): ...`\n- Enable `#![deny(missing_docs)]` for libraries\n",{"name":5,"license":14,"metadata":43,"description":46,"allowed-tools":47,"compatibility":48},{"author":44,"version":45},"apollographql","1.1.0","Guide for writing idiomatic Rust code based on Apollo GraphQL's best practices handbook. Use this skill when: (1) writing new Rust code or functions, (2) reviewing or refactoring existing Rust code, (3) deciding between borrowing vs cloning or ownership patterns, (4) implementing error handling with Result types, (5) optimizing Rust code for performance, (6) writing tests or documentation for Rust projects.\n","Bash(cargo:*) Bash(rustc:*) Bash(rustfmt:*) Bash(clippy:*) Read Write Edit Glob Grep","Rust 1.70+, Cargo","feature\u002Fconsolidate-codebase","b5c4cbf371c4b0147297859a7c98c6572c59e315",".cursor\u002Fskills\u002Frust-best-practices","https:\u002F\u002Fgithub.com\u002Fnovolei\u002Fif2Ai","https:\u002F\u002Fgithub.com\u002Fnovolei","2026-05-10 09:43:08",{"source":8,"skillName":5,"commands":56,"prompt":66,"zipAvailable":67},[57,60,63],{"tool":58,"command":59},"npx","npx skills add novolei\u002Fif2Ai --skill rust-best-practices",{"tool":61,"command":62},"bunx","bunx skills add novolei\u002Fif2Ai --skill rust-best-practices",{"tool":64,"command":65},"pnpm","pnpm dlx skills add novolei\u002Fif2Ai --skill rust-best-practices","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fnovolei\u002Fif2Ai\u002Fblob\u002Ffeature\u002Fconsolidate-codebase\u002F.cursor\u002Fskills\u002Frust-best-practices\u002FSKILL.md",true,[69,75,79,83,87,91,95,99,103],{"path":70,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":73,"sourceHtmlUrl":74},"references\u002Fchapter_01.md","REFERENCE","参考文档",17339,"https:\u002F\u002Fgithub.com\u002Fnovolei\u002Fif2Ai\u002Fblob\u002Ffeature\u002Fconsolidate-codebase\u002F.cursor\u002Fskills\u002Frust-best-practices\u002Freferences\u002Fchapter_01.md",{"path":76,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":77,"sourceHtmlUrl":78},"references\u002Fchapter_02.md",5453,"https:\u002F\u002Fgithub.com\u002Fnovolei\u002Fif2Ai\u002Fblob\u002Ffeature\u002Fconsolidate-codebase\u002F.cursor\u002Fskills\u002Frust-best-practices\u002Freferences\u002Fchapter_02.md",{"path":80,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":81,"sourceHtmlUrl":82},"references\u002Fchapter_03.md",8785,"https:\u002F\u002Fgithub.com\u002Fnovolei\u002Fif2Ai\u002Fblob\u002Ffeature\u002Fconsolidate-codebase\u002F.cursor\u002Fskills\u002Frust-best-practices\u002Freferences\u002Fchapter_03.md",{"path":84,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":85,"sourceHtmlUrl":86},"references\u002Fchapter_04.md",7082,"https:\u002F\u002Fgithub.com\u002Fnovolei\u002Fif2Ai\u002Fblob\u002Ffeature\u002Fconsolidate-codebase\u002F.cursor\u002Fskills\u002Frust-best-practices\u002Freferences\u002Fchapter_04.md",{"path":88,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":89,"sourceHtmlUrl":90},"references\u002Fchapter_05.md",14122,"https:\u002F\u002Fgithub.com\u002Fnovolei\u002Fif2Ai\u002Fblob\u002Ffeature\u002Fconsolidate-codebase\u002F.cursor\u002Fskills\u002Frust-best-practices\u002Freferences\u002Fchapter_05.md",{"path":92,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":93,"sourceHtmlUrl":94},"references\u002Fchapter_06.md",6813,"https:\u002F\u002Fgithub.com\u002Fnovolei\u002Fif2Ai\u002Fblob\u002Ffeature\u002Fconsolidate-codebase\u002F.cursor\u002Fskills\u002Frust-best-practices\u002Freferences\u002Fchapter_06.md",{"path":96,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":97,"sourceHtmlUrl":98},"references\u002Fchapter_07.md",8236,"https:\u002F\u002Fgithub.com\u002Fnovolei\u002Fif2Ai\u002Fblob\u002Ffeature\u002Fconsolidate-codebase\u002F.cursor\u002Fskills\u002Frust-best-practices\u002Freferences\u002Fchapter_07.md",{"path":100,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":101,"sourceHtmlUrl":102},"references\u002Fchapter_08.md",10132,"https:\u002F\u002Fgithub.com\u002Fnovolei\u002Fif2Ai\u002Fblob\u002Ffeature\u002Fconsolidate-codebase\u002F.cursor\u002Fskills\u002Frust-best-practices\u002Freferences\u002Fchapter_08.md",{"path":104,"resourceType":71,"resourceTypeDesc":72,"sizeBytes":105,"sourceHtmlUrl":106},"references\u002Fchapter_09.md",9570,"https:\u002F\u002Fgithub.com\u002Fnovolei\u002Fif2Ai\u002Fblob\u002Ffeature\u002Fconsolidate-codebase\u002F.cursor\u002Fskills\u002Frust-best-practices\u002Freferences\u002Fchapter_09.md",[]]