.cursor/skills/xfi-add-package/SKILL.md
Guide for creating a new package in the X-Fidelity monorepo. Use when adding new packages, setting up monorepo structure, or configuring workspace dependencies.
npx skillsauth add zotoio/x-fidelity xfi-add-packageInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill guides you through adding a new package to the X-Fidelity monorepo.
New Package Creation:
- [ ] Step 1: Create package directory structure
- [ ] Step 2: Create package.json
- [ ] Step 3: Create tsconfig.json
- [ ] Step 4: Create jest.config.js
- [ ] Step 5: Create source files
- [ ] Step 6: Register in root workspace
- [ ] Step 7: Update turbo.json if needed
- [ ] Step 8: Build and test
packages/x-fidelity-{name}/
├── src/
│ ├── index.ts # Main entry point and exports
│ └── *.ts # Source files
├── dist/ # Build output (gitignored)
├── package.json # Package configuration
├── tsconfig.json # TypeScript configuration
├── jest.config.js # Jest test configuration
├── jest.setup.js # Jest setup (if needed)
└── README.md # Package documentation
mkdir -p packages/x-fidelity-{name}/src
File: packages/x-fidelity-{name}/package.json
{
"name": "@x-fidelity/{name}",
"version": "0.0.0-semantically-released",
"description": "Description of the package",
"private": true,
"main": "dist/index.js",
"types": "dist/index.d.ts",
"module": "dist/index.js",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.js"
},
"./*": "./dist/*"
},
"scripts": {
"build": "tsc",
"clean": "rimraf dist",
"dev": "tsc --watch",
"test": "yarn check-types && yarn lint && jest",
"test:unit": "yarn check-types && yarn lint && jest",
"test:integration": "yarn check-types && yarn lint && jest --testMatch='**/*.integration.test.ts' --passWithNoTests",
"test:coverage": "yarn check-types && yarn lint && jest --coverage",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"check-types": "tsc --noEmit"
},
"repository": "[email protected]:zotoio/x-fidelity.git",
"author": "wyvern8 <[email protected]>",
"license": "MIT",
"engines": {
"node": ">=22.16.0",
"yarn": ">=1.22.0"
},
"devDependencies": {
"@types/jest": "^30.0.0",
"@types/node": "^22.10.5",
"eslint": "^9.29.0",
"jest": "^30.0.2",
"rimraf": "^6.0.1",
"ts-jest": "^29.4.0",
"typescript": "^5.8.3"
},
"dependencies": {}
}
To depend on other X-Fidelity packages:
{
"dependencies": {
"@x-fidelity/types": "workspace:*",
"@x-fidelity/core": "workspace:*"
}
}
File: packages/x-fidelity-{name}/tsconfig.json
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./dist",
"rootDir": "./src",
"tsBuildInfoFile": "./dist/.tsbuildinfo",
"isolatedModules": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"],
"references": []
}
If your package depends on other packages, add references:
{
"references": [
{ "path": "../x-fidelity-types" },
{ "path": "../x-fidelity-core" }
]
}
File: packages/x-fidelity-{name}/jest.config.js
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ['<rootDir>/src'],
testMatch: ['**/*.test.ts', '**/*.spec.ts', '!**/*.integration.test.ts'],
collectCoverageFrom: [
'src/**/*.ts',
'!src/**/*.test.ts',
'!src/**/*.spec.ts',
'!src/**/index.ts'
],
coverageDirectory: 'coverage',
coverageReporters: ['text', 'lcov', 'html', 'json', 'json-summary'],
// Coverage thresholds are managed centrally in ../../coverage-thresholds.config.js
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
moduleNameMapper: {
'^@x-fidelity/{name}/(.*)$': '<rootDir>/src/$1',
'^@x-fidelity/{name}$': '<rootDir>/src/index'
},
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node", "mts", "cts"],
testEnvironmentOptions: {
globalsCleanup: 'soft'
},
reporters: [
'default',
['<rootDir>/../../scripts/simple-json-reporter.js', {
outputPath: './jest-results.json'
}]
]
};
File: packages/x-fidelity-{name}/jest.setup.js
// Jest setup file
// Add any global test setup here
// Increase timeout for async tests
jest.setTimeout(30000);
File: packages/x-fidelity-{name}/src/index.ts
// Main entry point - export public API
export { myFunction } from './myFunction';
export type { MyType } from './types';
File: packages/x-fidelity-{name}/src/myFunction.ts
/**
* Example function
*/
export function myFunction(): string {
return 'Hello from {name}';
}
File: packages/x-fidelity-{name}/src/myFunction.test.ts
import { myFunction } from './myFunction';
describe('myFunction', () => {
it('should return greeting', () => {
expect(myFunction()).toBe('Hello from {name}');
});
});
Edit package.json at repository root:
{
"workspaces": {
"packages": [
"packages/x-fidelity-cli",
"packages/x-fidelity-core",
"packages/x-fidelity-{name}",
// ... other packages
]
}
}
If your package has special dependencies (like VSCode extension), add to nohoist:
{
"workspaces": {
"nohoist": [
"**/x-fidelity-{name}",
"**/x-fidelity-{name}/**"
]
}
}
If your package has special build requirements:
File: turbo.json
{
"pipeline": {
"x-fidelity-{name}#build": {
"dependsOn": ["@x-fidelity/types#build"],
"outputs": ["dist/**"]
}
}
}
# Install dependencies
yarn install
# Build all packages (respects dependencies)
yarn build
# Test your new package
yarn workspace @x-fidelity/{name} test
# Run all tests
yarn test
| Package Type | Name Format | Example |
|--------------|-------------|---------|
| Internal library | @x-fidelity/{name} | @x-fidelity/types |
| CLI tool | x-fidelity | Published to npm |
| VSCode extension | x-fidelity-vscode | Published to marketplace |
The dependency graph flows:
@x-fidelity/types
↓
@x-fidelity/core ← @x-fidelity/plugins
↓ ↓
x-fidelity (CLI) x-fidelity-vscode
Ensure your package fits correctly in this hierarchy.
# Add to specific package
yarn workspace @x-fidelity/{name} add some-package
# Add dev dependency
yarn workspace @x-fidelity/{name} add -D some-package
yarn workspace @x-fidelity/{name} build
yarn workspace @x-fidelity/{name} test
yarn workspace @x-fidelity/{name} dev
workspace:* for internal deps| Purpose | Location |
|---------|----------|
| Root workspace | package.json (root) |
| Turbo config | turbo.json |
| Base TypeScript | tsconfig.base.json |
| Coverage config | coverage-thresholds.config.js |
| Example package | packages/x-fidelity-types/ |
documentation
Guide for managing X-Fidelity releases using the unified release system. Use when releasing, versioning, troubleshooting release issues, or writing commit messages.
documentation
Guide for executing engineering plans through coordinated subagent work. Use when executing existing plans from knowledge/plans/ directory.
development
Guide for updating X-Fidelity documentation including README and website. Use when updating docs, adding new features to documentation, or ensuring docs stay in sync with code.
tools
Guide for debugging X-Fidelity analysis issues. Use when troubleshooting analysis failures, rule evaluation problems, VSCode extension issues, or unexpected results.