@sha3/code-standards
v0.1.22
Published
AI-first code standards, tooling exports, and project initializer
Downloads
2,028
Readme
📏 @sha3/code-standards
Scaffold TypeScript projects + enforce how AI writes code.
TL;DR
If you just want to start now:
npx @sha3/code-standards init --template node-service --yesIf your project was already scaffolded and you updated this package:
npx @sha3/code-standards refreshThen in your AI chat, paste this:
Before writing code:
1) Read AGENTS.md and ai/<assistant>.md in this repo.
2) List the blocking rules you will follow.
3) Implement the task following those rules.
4) Run npm run check and fix all issues.
5) Return changed files and which AGENTS rules were applied.profile is optional. Use it only when you want to customize AI behavior.
What This Tool Actually Does
This package combines 3 things in one:
- Project scaffolding (
init) fornode-libandnode-service. - Shared tooling exports (
eslint,prettier,tsconfig). - AI behavior contract generation (
AGENTS.md+ai/*.md) based on a style profile.
So it is not only formatting/linting. It also defines how AI should think and generate code.
Default generated contract includes structural class/file blocks such as:
imports:externalsimports:internalsconststypesprivate:attributesprotected:attributesprivate:propertiespublic:propertiesconstructorstatic:propertiesfactoryprivate:methodsprotected:methodspublic:methodsstatic:methods
Section marker format is fixed to:
/*** @section <block-name>*/
All blocks MUST exist even when empty (// empty).
Additional blocking defaults:
- Max line length is 160 chars, and lines should stay on one line when they fit.
if/else/loop statements MUST always use braces.- README updates MUST follow a top-tier quality standard (see
standards/readme.md).
Do I Need profile First?
No.
- If you run
initwithout profile flags, it uses the bundled default profile. - If you want your custom coding preferences, create a profile and pass it to
init.
Default flow (no profile setup):
npx @sha3/code-standards init --template node-service --yesCustom profile flow:
npx @sha3/code-standards profile --profile ./profiles/team.profile.json
npx @sha3/code-standards init --template node-service --yes --profile ./profiles/team.profile.jsonWhat Happens After init
After init, your new repo contains:
AGENTS.md(blocking rules for AI)ai/codex.md,ai/cursor.md,ai/copilot.md,ai/windsurf.mdai/examples/rules/*.ts(good/bad examples per rule)ai/examples/demo/src/*(feature-folder demo with classes and section blocks)src/config.tsfor centralized hardcoded configuration valuesREADME.mdgenerated with an icon emoji and complete integration docs (API + config + integration contract for other LLMs).gitignorepreconfigured for Node/TypeScript output.vscode/settings.json+.vscode/extensions.jsonfor autoformat-on-save and eslint autofix-on-save in VS Code- lint/format/typecheck/test-ready project template
package.json.codeStandardsmetadata used byrefresh(template,profilePath,withAiAdapters,lastRefreshWith)
config.ts convention: export a single default object and import it as import CONFIG from "./config.ts".
That means the next step is not configuring tools. The next step is telling your assistant to obey AGENTS.md before coding.
Generated project code is TypeScript-only: implementation and tests live in .ts files.
TypeScript Example Files
init now stores code examples in .ts files instead of embedding them inside AGENTS.md.
Demo structure generated by default:
ai/examples/demo/src/config.tsai/examples/demo/src/invoices/invoice-service.tsai/examples/demo/src/invoices/invoice-errors.tsai/examples/demo/src/invoices/invoice-types.tsai/examples/demo/src/billing/billing-service.ts
Rule-specific examples:
ai/examples/rules/class-first-good.tsai/examples/rules/class-first-bad.tsai/examples/rules/constructor-good.tsai/examples/rules/constructor-bad.tsai/examples/rules/functions-good.tsai/examples/rules/functions-bad.tsai/examples/rules/returns-good.tsai/examples/rules/returns-bad.tsai/examples/rules/async-good.tsai/examples/rules/async-bad.tsai/examples/rules/control-flow-good.tsai/examples/rules/control-flow-bad.tsai/examples/rules/errors-good.tsai/examples/rules/errors-bad.tsai/examples/rules/testing-good.tsai/examples/rules/testing-bad.ts
How To Use With AI (Copy/Paste)
Universal bootstrap prompt
Use this as your first message in any coding session:
Before generating code:
- Read AGENTS.md and ai/<assistant>.md.
- Summarize the blocking rules you must follow.
- Implement the task with those rules.
- Run npm run check and fix issues until it passes.
- Return changed files + a short compliance checklist.Task prompt template
Task: <describe task>
Constraints:
- Follow AGENTS.md and ai/<assistant>.md strictly.
- Keep architecture and naming conventions intact.
- Add/update tests for behavior changes.
- Run npm run check at the end.
Output:
- What changed
- Why
- Proof checks passedReplace <assistant> with:
codexcursorcopilotwindsurf
Assistant-Specific Start Commands
Use these prompts depending on tool:
Codex
Read AGENTS.md and ai/codex.md first. Do not start implementation until you summarize blocking rules.Cursor
Read AGENTS.md and ai/cursor.md. Enforce rules while implementing and keep edits compliant.GitHub Copilot Chat
Use AGENTS.md and ai/copilot.md as mandatory coding rules for this task.Windsurf
Read AGENTS.md and ai/windsurf.md and treat them as non-negotiable constraints.Quick Start (Step by Step)
1) Create profile (optional)
npx @sha3/code-standards profileNon-interactive:
npx @sha3/code-standards profile \
--non-interactive \
--profile ./profiles/team.profile.json \
--force-profile2) Scaffold project
Run this inside the directory you want to initialize.
npx @sha3/code-standards init --template node-service --yesWithout --yes, init prompts for:
- npm package name
- GitHub repository URL
With explicit profile:
npx @sha3/code-standards init \
--template node-lib \
--yes \
--no-install \
--profile ./profiles/team.profile.jsonSkip AI files when needed:
npx @sha3/code-standards init --template node-lib --yes --no-ai-adapters3) Work loop inside generated project
npm install
npm run checkThen use the prompts above in your AI tool.
4) Sync updates from @sha3/code-standards
Run this inside an already scaffolded project:
npx @sha3/code-standards refreshrefresh default behavior:
- scope
Managed + AI(package.json, config files,AGENTS.md,ai/*,ai/examples/*) - non-destructive for project source code (
src/**,test/**are preserved) - auto-detect template (or force with
--template) - selective merge for
package.json(managed scripts/devDependencies updated, custom keys preserved) - runs
npm run fixandnpm run checkautomatically after refreshing files - prints a ready-to-paste LLM prompt to reprocess updated conventions across the repository
- no dependency install unless
--install(use--installif dependencies are missing before auto-check)
CLI Reference
code-standards <command> [options]
Commands:
init Initialize a project in the current directory
refresh Re-apply managed standards files and AI instructions
update Alias of refresh
profile Create or update the AI style profileinit options
init always uses the current working directory as target.
An existing .git/ directory is allowed without --force.
--template <node-lib|node-service>--package-name <name>--repository-url <url>--yes--no-install--force--with-ai-adapters--no-ai-adapters--profile <path>
refresh options
refresh always uses the current working directory as target.
--template <node-lib|node-service>--package-name <name>--repository-url <url>--profile <path>--with-ai-adapters--no-ai-adapters--dry-run--install--yes
profile options
--profile <path>--non-interactive--force-profile
Package Exports
ESLint
// eslint.config.mjs
import nodeConfig from "@sha3/code-standards/eslint/node";
import testConfig from "@sha3/code-standards/eslint/test";
export default [...nodeConfig, ...testConfig];Prettier
// prettier.config.cjs
module.exports = require("@sha3/code-standards/prettier");TSConfig
{ "extends": "@sha3/code-standards/tsconfig/node-lib.json" }Local Quality Gates
Main gate:
npm run checkIncludes:
- standards schema validation
- profile schema validation
- lint
- format check
- typecheck
- smoke tests + CLI tests
Other scripts:
npm run fixnpm run standards:validatenpm run profile:validatenpm run release:checknpm run release:publish -- --dry-runnpm run release:publishnpm run hooks:install
FAQ
“I ran init. How do I force AI to follow rules?”
Always start with a bootstrap prompt that says:
- read
AGENTS.mdandai/<assistant>.md - summarize blocking rules
- implement
- run
npm run check
“AI ignored my standards.”
Use stricter prompt wording:
Treat AGENTS.md as hard constraints. If any rule conflicts with your default behavior, AGENTS.md wins.
If existing repository code conflicts with AGENTS.md, AGENTS.md and `@sha3/code-standards` conventions still win.
Do not modify `@sha3/code-standards` managed files (`AGENTS.md`, `ai/*`, `ai/examples/*`, tooling configs) unless explicitly requested.“Windsurf shows rvest.vs-code-prettier-eslint errors.”
Disable or uninstall rvest.vs-code-prettier-eslint in that workspace.
Use only:
esbenp.prettier-vscodedbaeumer.vscode-eslint
The rvest extension is not compatible with ESLint 9 flat config.
“Do I need to repeat the rules every task?”
Yes, practically you should restate that AGENTS is mandatory at each task boundary. Keep the prompt short and consistent.
“Can I use this without AI files?”
Yes, with --no-ai-adapters. You still get scaffold + tooling exports.
Repository Layout
.
├── bin/ # CLI entrypoint
├── profiles/ # AI style profile schema + defaults
├── resources/ai/ # templates for generated AGENTS/adapters
├── standards/ # canonical standards docs + manifest/schema
├── templates/ # project scaffolds (node-lib, node-service)
├── eslint/ # exported eslint configs
├── prettier/ # exported prettier config
└── tsconfig/ # exported tsconfig presetsPublishing
npm run release:check
npm run release:publishrelease:publish behavior:
- validates quality gates (unless
--skip-checks) - checks npm registry for
package.jsoncurrent version - if current version already exists on npm: runs
npm version minor --no-git-tag-versionautomatically - if current version does not exist on npm: keeps your manual version as-is
