8. File & Component Creation Rules
New File Locations
Required Files for New Packages
When adding a new package, all of the following files are required:
package.json— includes name, version, description, exports, bin, scripts, dependenciestsconfig.json— includes@commonpath alias,NodeNextmodule,noEmit: truetsup.config.ts— callscreateTsupConfig()src/index.ts—export { tools } from "./tools/index.js"+export { generateSkillMarkdown, generateReadmeSkills } from "@common"src/server.ts— MCP server creation and startupsrc/cli.ts— CLI executionsrc/tools/index.ts— tools re-exportsrc/tools/<name>.ts— actual tool definitions
Decision Guide for Modifying Existing Components
When to Extract Shared Logic
Extract to shared logic if any of these conditions apply:
- Same code used in 2+ packages → Move to
packages/common/kit/ - Same code used in 2+ tools within 1 package → Extract to a utility function within the package (e.g.,
cn.ts) - Complex Zod schema reused → Extract to a shared Zod schema