Skip to content

Scaffold a Lexicon

The fastest way to start a new lexicon is with chant init lexicon:

Terminal window
chant init lexicon k8s
cd lexicons/k8s
bun install

This 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.

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/

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.

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.