create-import-module

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Create Import Module

创建导入模块

Always use the skill
load-plain-reference
to retrieve the ***plain syntax rules — but only if you haven't done so yet.
请始终使用技能
load-plain-reference
来获取***plain语法规则——但仅在尚未获取的情况下使用。

What an Import Module Is

什么是导入模块

An import module is a
.plain
file that lives in the
template/
directory and contains only
***definitions***
,
***implementation reqs***
, and/or
***test reqs***
. It must not contain
***functional specs***
and must not use
requires
in its frontmatter. Other modules pull in its content via the
import
field in their YAML frontmatter, gaining access to its definitions and reqs.
Use import modules for:
  • Sharing concept definitions across multiple modules
  • Providing common implementation requirements (e.g., technology stack, coding standards)
  • Providing common test requirements
  • Creating reusable foundational structure (templates)
If the module needs functional specs (i.e., it describes what software should do), it is not an import module — see the
create-requires-module
skill.
导入模块是位于**
template/
**目录下的
.plain
文件,仅包含
***definitions***
***implementation reqs***
和/或
***test reqs***
。它绝对不能包含
***functional specs***
,且在其YAML前置元数据中不得使用
requires
字段。其他模块可通过其YAML前置元数据中的
import
字段引入其内容,从而获取其中的定义和要求。
导入模块适用于:
  • 在多个模块之间共享概念定义
  • 提供通用的实现要求(如技术栈、编码标准)
  • 提供通用的测试要求
  • 创建可复用的基础结构(模板)
如果模块需要包含功能规格(即描述软件应实现的功能),则它不是导入模块——请参考
create-requires-module
技能。

Workflow

工作流程

  1. Determine what shared content this module should provide — which definitions, implementation reqs, or test reqs will other modules need?
  2. Create the
    .plain
    file in the
    template/
    directory
    with YAML frontmatter. Use
    required_concepts
    to declare concepts that importing modules must define. It may optionally
    import
    other templates for layered reuse, but must not use
    requires
    .
  3. Add the shared content — definitions, implementation reqs, and/or test reqs.
  4. Do not add
    ***functional specs***
    — import modules must not contain functional specs.
  5. Verify concept availability — ensure all
    :Concepts:
    referenced are either defined in this module, provided by its own imports, declared as
    required_concepts
    , or are predefined concepts.
  1. 确定该模块应提供的共享内容——其他模块需要哪些定义、实现要求或测试要求?
  2. template/
    目录下创建带有YAML前置元数据的
    .plain
    文件
    。使用
    required_concepts
    声明导入模块必须定义的概念。它可以选择性地
    import
    其他模板以实现分层复用,但绝对不能使用
    requires
  3. 添加共享内容——定义、实现要求和/或测试要求。
  4. 不要添加
    ***functional specs***
    ——导入模块不得包含功能规格。
  5. 验证概念可用性——确保所有引用的
    :Concepts:
    要么在本模块中定义,要么由其自身导入的模板提供,要么被声明为
    required_concepts
    ,要么是预定义概念。

Format

格式

The
import
field is a list of module paths in the YAML frontmatter:
plain
---
import:
  - base_template
required_concepts: [":AppName:"]
description: Shared API definitions and reqs
---

***definitions***
- :ApiClient: is the HTTP client used to communicate with external services.
- :ApiResponse: is the response returned by :ApiClient:.

***implementation reqs***
- :Implementation: should handle HTTP errors by raising appropriate exceptions.
- :ApiClient: should support configurable timeouts.

***test reqs***
- :ConformanceTests: should mock all external HTTP calls made by :ApiClient:.
The default import directory is
template/
— the
template/
prefix is not needed in import paths. The
.plain
extension is omitted. Note the absence of
***functional specs***
— import modules must not have them.
import
字段是YAML前置元数据中的模块路径列表:
plain
---
import:
  - base_template
required_concepts: [":AppName:"]
description: Shared API definitions and reqs
---

***definitions***
- :ApiClient: is the HTTP client used to communicate with external services.
- :ApiResponse: is the response returned by :ApiClient:.

***implementation reqs***
- :Implementation: should handle HTTP errors by raising appropriate exceptions.
- :ApiClient: should support configurable timeouts.

***test reqs***
- :ConformanceTests: should mock all external HTTP calls made by :ApiClient:.
默认导入目录为
template/
——导入路径中无需添加
template/
前缀,也无需包含
.plain
扩展名。注意此处没有
***functional specs***
——导入模块不得包含该内容。

Satisfying Required Concepts

满足必填概念

If an imported template declares
required_concepts
, the importing module must define those concepts in its own
***definitions***
section:
plain
---
import:
  - auth_template
---

> auth_template declares required_concepts: [":AuthSchema:", ":AuthApiSpec:"]
> So this module must define them:

***definitions***
- :AuthSchema: is the JSON schema describing the authentication data structure.
- :AuthApiSpec: is the OpenAPI specification for the external service's auth endpoint.
如果导入的模板声明了
required_concepts
,则导入模块必须在其自身的
***definitions***
部分定义这些概念:
plain
---
import:
  - auth_template
---

> auth_template declares required_concepts: [":AuthSchema:", ":AuthApiSpec:"]
> So this module must define them:

***definitions***
- :AuthSchema: is the JSON schema describing the authentication data structure.
- :AuthApiSpec: is the OpenAPI specification for the external service's auth endpoint.

Import vs Requires

Import与Requires对比

Aspect
import
requires
Pulls in definitionsYesNo (only
exported_concepts
)
Pulls in implementation reqsYesNo
Pulls in test reqsYesNo
Pulls in functional specsNoYes (as previous requirements)
Copies generated codeNoYes
Typical useTemplates, shared definitionsBuild dependency chain
方面
import
requires
引入定义否(仅引入
exported_concepts
引入实现要求
引入测试要求
引入功能规格是(作为前置要求)
复制生成的代码
典型用途模板、共享定义构建依赖链

Validation Checklist

验证检查清单

  • Module file is in the
    template/
    directory
  • Module does not contain
    ***functional specs***
  • Module does not use
    requires
    in its frontmatter
  • Contains at least one of: definitions, implementation reqs, or test reqs
  • All
    required_concepts
    from any imports this module itself uses are satisfied
  • required_concepts
    declared for any concepts referenced but not defined here
  • No concept name collisions between this module's imports and local definitions
  • YAML frontmatter is correctly formatted between
    ---
    markers
  • 模块文件位于
    template/
    目录下
  • 模块包含
    ***functional specs***
  • 模块在前置元数据中使用
    requires
  • 至少包含以下内容之一:定义、实现要求或测试要求
  • 本模块使用的所有导入模板所声明的
    required_concepts
    均已满足
  • 所有被引用但未在此处定义的概念均已声明为
    required_concepts
  • 本模块的导入内容与本地定义之间不存在概念名称冲突
  • YAML前置元数据在
    ---
    标记之间格式正确