Agent Skillslikec4/likec4 › likec4-cli-codegen-regression

likec4-cli-codegen-regression

GitHub

用于 LikeC4 CLI 代码生成回归测试,确保多文件导出器遵守输出目录约束,防止路径穿越及外部引用越界。

.agents/skills/likec4-cli-codegen-regression/SKILL.md likec4/likec4

Trigger Scenarios

修改或审查 LikeC4 CLI 代码生成逻辑 修复 --outdir 参数相关 bug 检查生成文件是否逃逸输出文件夹 验证 dot/d2/mermaid/plantuml 输出行为

Install

npx skills add likec4/likec4 --skill likec4-cli-codegen-regression -g -y
More Options

Non-standard path

npx skills add https://github.com/likec4/likec4/tree/main/.agents/skills/likec4-cli-codegen-regression -g -y

Use without installing

npx skills use likec4/likec4@likec4-cli-codegen-regression

指定 Agent (Claude Code)

npx skills add likec4/likec4 --skill likec4-cli-codegen-regression -a claude-code -g -y

安装 repo 全部 skill

npx skills add likec4/likec4 --all -g -y

预览 repo 内 skill

npx skills add likec4/likec4 --list

SKILL.md

Frontmatter
{
    "name": "likec4-cli-codegen-regression",
    "description": "Use when changing or reviewing LikeC4 CLI code generation, exporters, output file naming, include-path codegen behavior, or `likec4 gen` commands. Trigger for bugs around `--outdir`, generated files escaping output folders, dot\/d2\/mermaid\/plantuml output, or external include-path views."
}

LikeC4 CLI Codegen Regression

Protect likec4 gen output contracts with focused tests. The most important invariant is that multi-file generators write every emitted view under the requested output directory.

Ground rules

  • Start in packages/likec4/src/cli/codegen.
  • Add a regression test before implementation when fixing a bug.
  • Test every affected multi-file format, not only the format that exposed the issue.
  • Treat external include-path views and Windows paths as first-class edge cases.

Output-path invariants

For likec4 gen dot, d2, mermaid or mmd, and plantuml:

  • --outdir or -o defines the containment root for all generated files.
  • Source-relative view paths must never escape the output root.
  • Absolute source paths, parent-relative paths, and Windows drive-root paths must not create files outside --outdir.
  • A view coming from an external include path should still be emitted under --outdir.
  • Define and assert the resulting output naming contract for escaped or external source paths; containment-only checks are not enough.
  • Single-file generators such as model, react, or webcomponent should keep their existing --outfile behavior.

Regression matrix

Cover the smallest matrix that proves the contract:

Case Expected result
view in project folder file under --outdir
view in nested project folder nested file under --outdir
view from external include path file under --outdir, not beside the included source
source path with .. relation to project sanitized or re-rooted under --outdir
Windows drive-style source path no drive-root escape such as C: output outside --outdir
absolute source path no absolute-root escape outside --outdir

Formats to consider:

  • .dot
  • .d2
  • .mmd
  • .puml

Test shape

Use a temp workspace fixture:

workspace/
  project-a/
    likec4.config.ts
    project-view.c4
  shared/
    included-view.c4
  out/

Configure project-a to include ../shared. Run each generator with --outdir workspace/out.

Assert:

  • expected files exist inside workspace/out
  • escaped or external source paths use the explicitly chosen output naming contract
  • no generated file exists under project-a, shared, or the temp workspace root outside out
  • all generated paths pass an isInside(outdir, filepath) style check

If the real fixture cannot produce absolute or Windows drive-style sourcePath values, extract a small path-resolution helper and cover those cases with pure unit tests.

Focused commands

pnpm --filter likec4 test -- codegen
pnpm --filter likec4 typecheck
pnpm exec dprint check packages/likec4/src/cli/codegen
git diff --check

If touching shared path utilities, also run the package tests that own those utilities.

Version History

  • 84ff665 Current 2026-08-20 13:06

Same Skill Collection

.agents/skills/add-new-element-shape/SKILL.md
.agents/skills/changeset-generator/SKILL.md
.agents/skills/dispatching-parallel-agents/SKILL.md
.agents/skills/likec4-gh-pr-triage/SKILL.md
.agents/skills/likec4-issue-repro/SKILL.md
.agents/skills/likec4-project-config-workflow/SKILL.md
.agents/skills/refactor/SKILL.md
.agents/skills/vscode-extension-screenshot-evidence/SKILL.md
skills/likec4-dsl/SKILL.md

Metadata

Files
0
Version
84ff665
Hash
c210158e
Indexed
2026-08-20 13:06

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-25 13:49
浙ICP备14020137号-1 $방문자$