技能 nx-workspace-patterns
📦

nx-workspace-patterns

安全

配置 Nx Monorepo 工作区

也可从以下获取: wshobson

在没有合适工具的情况下管理大规模 JavaScript 项目会变得复杂。此技能提供生产就绪的 Nx 工作区模式,通过构建缓存和受影响命令实现高效的单仓库管理。

支持: Claude Codex Code(CC)
🥉 75 青铜
1

下载技能 ZIP

2

在 Claude 中上传

前往 设置 → 功能 → 技能 → 上传技能

3

开启并开始使用

测试它

正在使用“nx-workspace-patterns”。 Configure nx.json with caching for build, test, and lint operations

预期结果:

Provides complete nx.json configuration with tasksRunnerOptions, targetDefaults, namedInputs, and cacheable operations for optimal CI performance.

正在使用“nx-workspace-patterns”。 Set up module boundaries preventing circular dependencies

预期结果:

Generates ESLint configuration with depConstraints enforcing tag-based dependency rules between apps, features, UI libraries, and utilities.

安全审计

安全
v1 • 2/24/2026

Static analysis flagged 35 patterns that are all false positives. The SKILL.md file is documentation-only content containing Nx configuration templates, CLI command examples, and best practices. External command patterns are documentation code blocks, network references are hyperlinks to official Nx documentation, and filesystem patterns are JSON schema paths in configuration templates. No executable code or security risks present.

1
已扫描文件
467
分析行数
0
发现项
1
审计总数
未发现安全问题
审计者: claude

质量评分

38
架构
100
可维护性
87
内容
50
社区
100
安全
100
规范符合性

你能构建什么

新建 Nx 工作区设置

为开始大规模 React 应用程序的团队配置新的 Nx monorepo,包括正确的项目结构、缓存和任务运行器选项。

CI 流水线优化

在 GitHub Actions 中实现受影响命令,仅对更改的项目进行测试和构建,从而减少 CI 时间。

模块边界强制执行

设置 ESLint 规则,在整个组织内强制执行功能库、UI 库和工具库之间的架构边界。

试试这些提示

Basic Workspace Configuration
Help me set up a new Nx workspace for a React application with proper caching configuration.
Project Boundary Setup
Generate ESLint module boundary rules for an Nx workspace with apps and libs directories, enforcing that apps can depend on features and utilities but features cannot depend on other features.
CI Workflow with Affected Commands
Create a GitHub Actions workflow that uses Nx affected commands to run lint, test, and build only on changed projects when pulling from main branch.
Custom Library Generator
Write a custom Nx generator that creates a feature library with pre-configured tags, index exports, and barrel files for a scoped monorepo structure.

最佳实践

  • 一致地使用描述性标签,并通过模块边界规则强制执行
  • 在项目设置早期启用构建缓存,可显著节省 CI 时间
  • 保持库的专注性和单一职责,以维护清晰的依赖关系

避免

  • 在库之间创建循环依赖,这会破坏依赖图
  • 跳过受影响命令,在每次提交时运行完整的测试套件
  • 过度细分为太多小库,增加维护负担

常见问题

Nx affected 和运行所有任务有什么区别?
受影响命令仅对自基提交以来更改的项目运行任务,与在所有项目上运行相比,可显著减少 CI 时间。
Nx 缓存如何工作?
Nx 基于源文件和配置等输入来缓存任务输出。当输入与之前的运行匹配时,Nx 会恢复缓存结果而不是重新执行。
什么是模块边界,为什么要使用它们?
模块边界是强制执行架构约束的 ESLint 规则,可防止库类型和作用域之间的不当依赖。
缓存需要 Nx Cloud 吗?
不需要,本地缓存可以在没有 Nx Cloud 的情况下工作。Nx Cloud 启用跨团队成员和 CI 运行器的分布式缓存,以获得额外的性能提升。
如何将现有工作区迁移到 Nx?
使用 nx migrate 命令将 Nx 添加到现有项目。首先添加 nx 包,然后逐步将 package.json 脚本转换为 Nx 目标。
在 Nx 工作区中应该使用哪些库类型?
常见类型包括:用于业务逻辑的 feature、用于展示组件的 ui、用于 API 集成的 data-access、用于纯函数的 util、用于应用引导的 shell。

开发者详情

文件结构

📄 SKILL.md