8. File & Component Creation Rules

New File Locations

What to CreateLocationExample
New MCP server packagepackages/<name>/packages/date/
New tool in existing packagepackages/<name>/src/tools/<name>.tspackages/core/src/tools/network.ts
Tool group re-exportpackages/<name>/src/tools/index.tsAdd export to existing file
Shared kit featurepackages/common/kit/<name>.tspackages/common/kit/validator.ts
Shared kit re-exportpackages/common/kit/index.tsAdd export to existing file
Shared typespackages/common/types.tsAdd types to existing file
Shared constantspackages/common/constants.tsAdd constants to existing file

Required Files for New Packages

When adding a new package, all of the following files are required:

  1. package.json — includes name, version, description, exports, bin, scripts, dependencies
  2. tsconfig.json — includes @common path alias, NodeNext module, noEmit: true
  3. tsup.config.ts — calls createTsupConfig()
  4. src/index.tsexport { tools } from "./tools/index.js" + export { generateSkillMarkdown, generateReadmeSkills } from "@common"
  5. src/server.ts — MCP server creation and startup
  6. src/cli.ts — CLI execution
  7. src/tools/index.ts — tools re-export
  8. src/tools/<name>.ts — actual tool definitions

Decision Guide for Modifying Existing Components

SituationAction
Add new toolCreate new file in src/tools/ OR add to existing file (if same domain)
Modify existing tool logicOnly modify the tool's handler (no need to split files)
Change shared behaviorModify packages/common/kit/ + rebuild all packages
Change CLI output formatModify formatSkills() in packages/common/kit/cli.ts
Change README formatModify packages/common/build/update-readme.mjs

When to Extract Shared Logic

Extract to shared logic if any of these conditions apply:

  1. Same code used in 2+ packages → Move to packages/common/kit/
  2. Same code used in 2+ tools within 1 package → Extract to a utility function within the package (e.g., cn.ts)
  3. Complex Zod schema reused → Extract to a shared Zod schema

Common Naming Rules

ItemRuleExample
Package name@julong/<description>@julong/mono-rele2-core
CLI binary name<package-name>-climono-rele2-core-cli
Tool name (variable)camelCase + Tool suffixechoTool, timestampTool
Tool name (MCP exposed)snake_caseecho, case_convert
File namekebab-caseupdate-readme.mjs, case-convert.ts
InterfacePascalCaseToolDefShape, AnyToolDef
Type (utility)PascalCaseNullable<T>, Optional<T>
Async functionasync functionAll tool handlers
ConstantUPPER_SNAKE_CASEVERSION