Scaffold a Lexicon
The fastest way to start a new lexicon is with chant init lexicon:
chant init lexicon k8scd lexicons/k8sbun installThis scaffolds a complete lexicon project with compilable stubs for every required lifecycle method. Follow the TODO comments in the generated files to wire up your upstream spec.
See the init lexicon CLI reference for the full list of options and flags.
Generated File Walkthrough
Section titled “Generated File Walkthrough”The scaffold creates a standard lexicon project layout:
lexicons/k8s/├── package.json npm package config├── tsconfig.json TypeScript config├── src/│ ├── index.ts LexiconPlugin export│ ├── serializer.ts Serializer stub│ ├── codegen/│ │ ├── generate.ts Generation pipeline stub│ │ ├── naming.ts NamingStrategy config│ │ └── package.ts Packaging pipeline stub│ ├── spec/│ │ └── fetch.ts Schema fetching stub│ ├── lsp/│ │ ├── completions.ts LSP completion provider│ │ └── hover.ts LSP hover provider│ └── generated/ (output directory for generatePipeline)│ ├── index.ts Runtime factories (createResource/createProperty)│ ├── index.d.ts TypeScript declarations│ └── lexicon.json Resource registry└── dist/ (output directory for packagePipeline) ├── manifest.json ├── meta.json ├── integrity.json ├── types/index.d.ts ├── rules/ └── skills/Key files
Section titled “Key files”src/index.ts — The entry point. Exports the LexiconPlugin object that wires together all the lifecycle methods:
import type { LexiconPlugin } from "@intentius/chant";import { mySerializer } from "./serializer";
export const myPlugin: LexiconPlugin = { name: "k8s", serializer: mySerializer, async generate(opts) { /* ... */ }, async validate(opts) { /* ... */ }, async coverage(opts) { /* ... */ }, async package(opts) { /* ... */ },};src/codegen/generate.ts — Where you call core’s generatePipeline with your provider-specific callbacks. This is where most of the implementation work happens. See Implement Generate.
src/serializer.ts — Converts evaluated resources to your target format. See Create a Serializer.
src/codegen/package.ts — Calls core’s packagePipeline to produce a distributable bundle. See Package & Publish.
Next Steps
Section titled “Next Steps”With the scaffold in place, your next step is to implement the generation pipeline — connecting your upstream spec to chant’s generatePipeline.
Once your lexicon is fully built and packaged, run chant dev onboard to wire it into CI, Docker smoke tests, and the npm publish workflow. See the full authoring workflow for all steps.