codegen
Use when the user asks to generate an API client or server stubs from an OpenAPI spec, scaffold a project or component, or apply the same mechanical change across many files (a codemod, a rename, an API migration).
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- codegen
- description
- Use when the user asks to generate an API client or server stubs from an OpenAPI spec, scaffold a project or component, or apply the same mechanical change across many files (a codemod, a rename, an API migration).
02 资源文件 1
- 其他.codex-harness6 B
03 SKILL.md 正文
Code generation
Generators and codemods are deterministic: the same input gives the same output, at no token cost. Prefer them to writing repetitive code by hand.
Rules
- The generation command lives in the repo: an npm script, an MSBuild target, a
scripts/file or the generator's own config file. Anyone can rerun it. - Never edit generated files by hand. Change the input or the generator's config and regenerate.
- Pin the generator version in the repo's dev dependencies or tool manifest.
- Review the generated diff like any other diff, then run the build and tests.
OpenAPI clients
| Stack | Tool | Command |
|---|---|---|
| .NET | NSwag | dotnet new tool-manifest once, dotnet tool install NSwag.ConsoleCore, keep an nswag.json, then DOTNET_CLI_TELEMETRY_OPTOUT=1 dotnet nswag run nswag.json |
| .NET, TS, Python | Kiota | KIOTA_CLI_TELEMETRY_OPTOUT=1 kiota generate -l CSharp -d openapi.yaml -o src/Client -n My.Client -c ApiClient (-l TypeScript, -l Python) |
| TS, Python | openapi-generator | npx @openapitools/openapi-generator-cli generate -i openapi.yaml -g typescript-fetch -o src/client (-g python); needs Java, and the first run downloads the generator jar |
Kiota sends usage telemetry unless KIOTA_CLI_TELEMETRY_OPTOUT=1 is set; set it in the script, not only in your shell.
Windows PowerShell has no NAME=value command form: write the variable first in the same command, for example $env:DOTNET_CLI_TELEMETRY_OPTOUT = '1'; dotnet test.
Codemods with ast-grep
ast-grep matches syntax, not text, so it does not touch strings or comments that merely look like code.
ast-grep run --lang ts --pattern 'console.log($A)' --rewrite 'logger.debug($A)' # preview
ast-grep run --lang ts --pattern 'console.log($A)' --rewrite 'logger.debug($A)' --update-all
For a change applied more than once, write a rule file and keep it in the repo (sgconfig.yml plus rules/), then ast-grep scan --update-all. Languages include C#, TypeScript, JavaScript and Python.
Scaffolding
Use the stack's own templates: dotnet new <template> (with DOTNET_CLI_TELEMETRY_OPTOUT=1), npm create <template>, or a template the repo already has. Do not invent a project layout the repo does not follow.
After generating
Then run the repository's own build and test commands (from its README, AGENTS.md or CI configuration) and harness analyze --base main, and report what changed, which generator or script made the change, and the build, test and analysis results.
04 同仓库更多 Skills
web-consensus
Use when a question has to be settled against the live web rather than from memory - researching a topic, proving or disproving a claim, checking whether something is still true, a sourced second opinion on a factual question - or when the user says "research", "prove it", "with sources", "check if this is true", "still accurate?".
skill-validate
Use when a SKILL.md is about to ship or was just edited, when a skill is reviewed or audited, when a skill seems ignored, skipped or misread by agents, or when the user says "validate this skill", "lint the skill", "check my skill", "is this skill any good".
regression-tests
Use when fixing a bug, changing behaviour or adding a feature in code that has tests, or when the user asks whether a change is covered by tests, wants regression tests, or wants coverage of the changed lines.
redacao
Use when writing, rewriting or editing a technical article or blog post in Portuguese, or when the user says "escreve um artigo", "reescreve o post", "redação", "pauta", "revisa o texto", "tira a cara de IA".
improve
Use when the user asks to improve the harness, its rules, Guardian policy, skills or knowledge from experience on this machine, or says "remember this for next time", "make this a rule", "teach the harness".
hld-trace
Use when the user asks whether the code follows the high-level design (HLD), which requirements have tests, which are untested, or wants tests linked to requirement or work item IDs.