跳到正文
cccskills
免费在 GitHub 公开

cross-platform

Guidelines for writing platform-specific code in Luma. Use when adding or modifying code that behaves differently on Unix vs Windows, including shell commands, file paths, process spawning, or platform-specific tests.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(1)

  • SKILL.md1.3 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Cross-Platform Code in Luma

Compile-time selection

Prefer compile-time platform selection over runtime branching:

// Preferred
#[cfg(unix)]
fn shell_command() -> &'static str { "sh" }

#[cfg(windows)]
fn shell_command() -> &'static str { "cmd" }

// Avoid
fn shell_command() -> &'static str {
    if cfg!(windows) { "cmd" } else { "sh" }
}

Use #[cfg(unix)], #[cfg(windows)], or module-level #[cfg(...)] attributes.

Module layout

Platform-specific code lives in separate files:

src/tool/shell/
  mod.rs        ← public API, platform-agnostic
  unix.rs       ← #[cfg(unix)]
  windows.rs    ← #[cfg(windows)]

The parent module exposes a single unified API. Callers never import platform modules directly.

Tests

Guard platform-specific tests at compile time:

#[cfg(test)]
mod tests {
    #[cfg(unix)]
    #[test]
    fn unix_specific_behavior() { ... }

    #[cfg(windows)]
    #[test]
    fn windows_specific_behavior() { ... }
}

Do not duplicate test logic when expectations can be shared across platforms.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Rules for numeric type conversions in Luma. Use when writing or reviewing code that casts between integer or float types, especially across different widths.

中文简介正在准备中。当前显示原文说明。

nghyane/luma202026年6月8日 更新

rfc

免费

Workflow for creating, updating, or superseding RFCs in Luma. Use when the task involves opening a new RFC, updating RFC status, marking an RFC as superseded or implemented, or deciding whether a change needs an RFC at all.

中文简介正在准备中。当前显示原文说明。

nghyane/luma202026年6月8日 更新

查看 nghyane 的全部技能

报告此技能的问题