vercel-labs/konsistent-config
> Create or modify a konsistent.json configuration file that enforces structural conventions in a TypeScript codebase. Use when the user wants to enforce consistent code structure, validate exports/imports across files, ensure directories contain required files, enforce naming patterns, add/remove/update convention rules, configure case map overrides for acronyms or special casing (kebabToPascalMap, kebabToCamelMap), or troubleshoot why konsistent is reporting violations. "consistent exports", "consistent structure", "code conventions config", "add convention", "update convention", "fix konsistent errors", "case map", "case override", "acronym casing".
npx skills add https://github.com/vercel-labs/konsistent --skill konsistent-config
Create or modify a konsistent.json file that enforces structural conventions for the project. The konsistent CLI checks filesystem structure and TypeScript exports/imports — it is not a style linter.
Important reminder: DO NOT write a konsistent.json file that leads to zero errors when running the konsistent check. That would defeat the purpose. The objective is to create a konsistent.json file that identifies violations to patterns used in the codebase, even if they are not being 100% adhered to. Add conventions based on dominant patterns in the codebase, even if other instances violate those patterns.
Treat the existing codebase as evidence from which to infer conventions, not as a specification that every convention must accept. Existing files that do not follow a dominant pattern are expected findings, not proof that the convention is wrong.
A successful configuration can make konsistent exit with violations. The violations are the intended audit output. Only konsistent validate is expected to pass without errors.
konsistent CLI (only if not set up yet)Check if the konsistent package is already installed:
konsistent available in root package.jsonnode_modules/konsistent directory existskonsistent script exists in package.jsonIf not, the konsistent CLI must be installed first. Use the project's package manager. For example, with PNPM:
pnpm add konsistent --save-dev
Then, ensure package.json has a konsistent script which invokes the konsistent CLI. At a minimum:
"scripts": {
"konsistent": "konsistent"
}
If or once all of these are ready, proceed to section 2.
konsistent.json Filekonsistent.json already exists at the project root.node_modules/konsistent/konsistent.schema.json to confirm the authoritative shape.node_modules/konsistent/docs/ (see References below) before making changes.konsistent.json exists: read it, then add/remove/update conventions as requested by the user.konsistent.json does not exist: create it at the project root.konsistent.json FileExplore the user's codebase to understand existing structure and naming patterns. Refer to node_modules/konsistent/docs/guides/exploring-codebases.md for what to look out for.
Make sure you review the codebase for structural conventions _holistically_. For large codebases with multiple layers of nested subdirectories, consider using subagents for individual sections of the codebase. Make each subagent aware of all the analysis requirements outlined in the following subsections, and use subagents to gather raw evidence rather than make final dominance decisions.
When subagents explore separate sections, ensure their findings can be combined into complete relevant cohorts. Each subagent must report the scope it examined, the total instances in that scope, conforming and nonconforming counts, competing patterns, and representative examples. The primary agent must merge these findings, reconstruct each complete cohort, and decide dominance using the combined evidence. A pattern that is dominant within one delegated section is not necessarily dominant across the complete cohort.
Consider conventions between related files as well, not only within a single file. Use the haveFiles predicate to ensure a specific other file exists based on the matched file, and use for.files to enforce conventions within specific other related files based on the matched file.
Do not write the configuration until you have recorded the evidence for each candidate convention. For every candidate:
haveFiles predicate to ensure a specific other file exists based on the matched file, and use for.files to enforce conventions within specific other related files based on the matched file.Use an evidence table while exploring:
| Candidate convention | Cohort | Follows | Violates | Competing patterns | Decision |
| --- | --- | ---: | ---: | --- | --- |
| Every package has src/index.ts | 12 packages | 10 | 2 | None | Enforce |
| Service files use the -service suffix | 9 service files | 5 | 4 | -service vs. -svc | Ambiguous; ask user |
Do not invent conditions that make all competing variants valid. If the evidence is ambiguous, pause and ask the user which convention to enforce or whether to enforce none of them.
Before translating a candidate into configuration, try to disprove it:
The purpose of this review is to reject weak or invented patterns. It is not to eliminate violations of strong patterns.
When modifying an existing config:
name, description, and severity values unless asked to change them.conventions array.NEVER optimize the configuration for any of the following outcomes:
severity of "warning" just to make the CLI pass with exit code 0.Do not weaken, narrow, condition, or exclude a convention solely because existing code violates it.
Validate the generated config by running konsistent validate via the package.json script (e.g. pnpm konsistent validate).
After validation succeeds, freeze the evidence-based configuration and audit the actual codebase by running konsistent via the package.json script with no arguments. Treat reported violations as audit findings, not as configuration failures.
A post-audit configuration change is allowed only when one of the following is true:
konsistent schema or predicate API incorrectly.“Existing files fail this rule” is never sufficient justification for changing the configuration. For every post-audit change, state which allowed reason applies and update the recorded evidence when relevant.
All canonical documentation lives in node_modules/konsistent/docs/ (published with the package). Read these before authoring config:
node_modules/konsistent/docs/reference/configuration.md — top-level konsistent.json shape (version, conventions, severity, excludeFiles).node_modules/konsistent/docs/reference/predicates.md — every must predicate (haveType, haveFiles, export, exportTypes, exportConstants, exportFunctions, exportInterfaces, exportClasses, import, importTypes).node_modules/konsistent/docs/reference/path-patterns.md — globs, placeholders, case transformations (toPascalCase, toCamelCase, toFlatCase, toNthSegment, extract, …), negation.node_modules/konsistent/docs/reference/constraints.md — matches, segments for inline path constraints and if.placeholderSatisfies.node_modules/konsistent/docs/reference/conditional-rules.md — if / for / excludeFiles blocks when must is an array.node_modules/konsistent/docs/reference/case-maps.md — kebabToPascalMap, kebabToCamelMap for acronyms and special casing.node_modules/konsistent/docs/guides/examples.md — copy-pasteable common patterns (provider packages, factories, adapters, conditional rules, …).node_modules/konsistent/docs/guides/exploring-codebases.md — pattern-identification approach before writing rules.name on conventions to give them identifiable IDs (must be kebab-case).description when the convention name alone isn't self-explanatory.konsistent's key strength.* in declaration or export names. These wildcards are only allowed in path segments.When handing off the configuration, report:
Do not describe success as “konsistent passes.” Distinguish schema validation success from the codebase audit findings.
Take vercel-labs/konsistent-config from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.
The instructions reference pnpm.
Without those the skill loads but fails at the first command.