packaging-rules
BrainDrive plugin packaging and ZIP rules - use when creating the final distributable package or validating ZIP structure
Best use case
packaging-rules is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
BrainDrive plugin packaging and ZIP rules - use when creating the final distributable package or validating ZIP structure
Teams using packaging-rules should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/packaging-rules/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How packaging-rules Compares
| Feature / Agent | packaging-rules | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
BrainDrive plugin packaging and ZIP rules - use when creating the final distributable package or validating ZIP structure
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
## What is the Final Plugin Package?
A BrainDrive plugin is distributed as a **ZIP file** that users can install via the Plugin Installer UI.
### ZIP Contents
```
my-plugin-1.0.0.zip
└── my-plugin/ # Plugin folder name
├── package.json # npm metadata
├── lifecycle_manager.py # Backend lifecycle hooks
├── webpack.config.js # Build configuration
├── tsconfig.json # TypeScript configuration
├── src/ # Source code
│ ├── index.tsx
│ ├── MyPlugin.tsx
│ ├── MyPlugin.css
│ ├── types.ts
│ ├── components/
│ ├── services/
│ └── utils/
├── public/ # Static assets
│ └── icon.png
├── dist/ # Build output (MUST exist)
│ ├── remoteEntry.js # Module Federation entry (REQUIRED)
│ ├── main.js
│ └── ... other chunks
├── README.md # Installation/usage instructions
├── LICENSE # License file
├── .npmignore # Files to exclude from npm (if publishing)
└── (optional) CHANGELOG.md
```
## ZIP File Naming
### Format
```
{plugin-slug}-{version}.zip
```
### Examples
```
✅ VALID
- my-plugin-1.0.0.zip
- task-manager-0.1.0.zip
- data-dashboard-2.3.1.zip
❌ INVALID
- my-plugin.zip (missing version)
- my-plugin-v1.0.0.zip (has "v" prefix)
- my-plugin-latest.zip (not semver)
- my_plugin-1.0.0.zip (uses underscore)
```
## Build Output Requirements
### MUST Include: dist/ Folder
Before creating the ZIP, run the build:
```bash
npm install
npm run build
```
This creates the `dist/` folder with:
- **dist/remoteEntry.js** (REQUIRED) - Module Federation entry point
- **dist/main.js** - Your plugin code bundle
- **dist/{other-chunks}.js** - Split code chunks if any
### MUST Exist Before ZIP
```bash
# Verify dist folder and remoteEntry.js exist
ls -la dist/
# Output:
# -rw-r--r-- main.js
# -rw-r--r-- remoteEntry.js
```
### Build Configuration (webpack.config.js)
```javascript
const { ModuleFederationPlugin } = require('webpack').container;
module.exports = {
mode: 'production',
entry: './src/index.tsx',
output: {
path: __dirname + '/dist',
filename: 'main.js',
publicPath: 'auto' // Critical for Module Federation
},
plugins: [
new ModuleFederationPlugin({
name: 'MyPlugin', // Must match plugin_slug
filename: 'remoteEntry.js', // MUST be exactly this
exposes: {
'./index': './src/index.tsx'
},
shared: {
react: { singleton: true, requiredVersion: '^18.2.0' },
'react-dom': { singleton: true, requiredVersion: '^18.2.0' }
}
})
]
};
```
## Step-by-Step Packaging Process
### Step 1: Verify Source Code
```bash
# Check that all source files exist
ls -la
# Files MUST exist:
# - package.json
# - lifecycle_manager.py
# - webpack.config.js
# - tsconfig.json
# - src/index.tsx
```
### Step 2: Install Dependencies
```bash
npm install
```
### Step 3: Build for Production
```bash
npm run build
```
Verify build output:
```bash
ls -la dist/
# Must show:
# remoteEntry.js
# main.js
```
### Step 4: Verify dist/ Folder Size
```bash
du -sh dist/
# Typical plugin: 100KB - 500KB
# If > 2MB: check for large dependencies or assets
```
### Step 5: Create ZIP File
Using command line:
```bash
# Option 1: Include dist/
zip -r my-plugin-1.0.0.zip my-plugin/
# Option 2: Manual folder structure
mkdir package_dir
cp -r my-plugin/* package_dir/
cd package_dir
zip -r ../my-plugin-1.0.0.zip .
cd ..
rm -rf package_dir
```
Using Node.js:
```javascript
const archiver = require('archiver');
const fs = require('fs');
const output = fs.createWriteStream('my-plugin-1.0.0.zip');
const archive = archiver('zip', { zlib: { level: 9 } });
output.on('close', () => {
console.log('ZIP created:', archive.pointer() + ' total bytes');
});
archive.pipe(output);
archive.directory('my-plugin/', 'my-plugin');
archive.finalize();
```
### Step 6: Verify ZIP Contents
```bash
# List ZIP contents
unzip -l my-plugin-1.0.0.zip
# Should show structure like:
# my-plugin-1.0.0/my-plugin/package.json
# my-plugin-1.0.0/my-plugin/lifecycle_manager.py
# my-plugin-1.0.0/my-plugin/dist/remoteEntry.js
# ... etc
```
### Step 7: Store ZIP
- **For distribution:** Upload to plugin marketplace
- **For installation:** Keep ZIP file available locally
- **For backup:** Store with version tag
## What NOT to Include in ZIP
❌ **Exclude These:**
- `node_modules/` (too large, users will run npm install)
- `.git/` (version control files)
- `.gitignore`
- `.env` (sensitive data)
- `src/` (source code, not needed for runtime)
- `*.log` (log files)
- `.DS_Store` (macOS metadata)
- `Thumbs.db` (Windows metadata)
- `dist/` if it's pre-built (users may build differently)
❌ **Actually, reconsider `dist/`:**
- **Pro:** Users don't need to build, faster install
- **Con:** Large ZIP, platform-specific build artifacts
- **Recommendation:** Include `dist/` for end users, exclude for developers
### .npmignore or Similar
If you want different files for npm publishing vs plugin distribution, create `.npmignore`:
```
# .npmignore
dist/
node_modules/
.git
.env
*.log
screenshot/
docs/
```
## Installation Instructions (Include in README.md)
```markdown
## Installation
1. Download the plugin ZIP file
2. Open BrainDrive
3. Go to Settings → Plugins → Install Plugin
4. Select the ZIP file
5. BrainDrive will install the plugin and reload
6. Plugin appears in the sidebar / main menu
## Building from Source
If you have the source code:
```bash
npm install
npm run build
zip -r my-plugin-1.0.0.zip my-plugin/
```
Then follow installation steps above.
```
## Validation Before Packaging
Run this checklist:
```bash
# ✅ Verify essential files exist
[ -f package.json ] && echo "✓ package.json"
[ -f lifecycle_manager.py ] && echo "✓ lifecycle_manager.py"
[ -f webpack.config.js ] && echo "✓ webpack.config.js"
[ -f tsconfig.json ] && echo "✓ tsconfig.json"
[ -d src ] && echo "✓ src/ folder"
[ -d dist ] && echo "✓ dist/ folder"
[ -f dist/remoteEntry.js ] && echo "✓ dist/remoteEntry.js"
# ✅ Verify version consistency
echo "package.json version:"
grep '"version"' package.json
echo "lifecycle_manager.py version:"
grep '"version"' lifecycle_manager.py
# ✅ Verify plugin_slug matches scope
echo "plugin_slug:"
grep 'plugin_slug' lifecycle_manager.py
echo "webpack scope:"
grep "name: '" webpack.config.js
# ✅ Verify no sensitive data
! grep -r 'API_KEY\|SECRET\|PASSWORD' src/ && echo "✓ No hardcoded secrets"
! [ -f .env ] && echo "✓ No .env file"
```
## ZIP Size Guidelines
| Size | Status | Recommendation |
|------|--------|-----------------|
| < 100 KB | ✅ Excellent | Small, fast download |
| 100 KB - 500 KB | ✅ Good | Typical for feature-rich plugins |
| 500 KB - 2 MB | ⚠️ Large | Consider optimizing dependencies |
| > 2 MB | ❌ Too Large | Likely includes unnecessary files |
## Optimization Tips
If your ZIP is too large:
1. **Remove node_modules before zipping:**
```bash
rm -rf node_modules/
zip -r my-plugin-1.0.0.zip my-plugin/
```
2. **Exclude src/ if dist/ exists:**
```bash
zip -r my-plugin-1.0.0.zip my-plugin/ -x "my-plugin/src/*"
```
3. **Minimize dependencies:**
```bash
# Remove unused packages
npm prune --production
```
4. **Check for large assets:**
```bash
find dist/ -size +100k
```
## Common Packaging Mistakes
❌ **Missing dist/remoteEntry.js**
```bash
# Forgot to build!
npm run build # Fix this first
```
❌ **Version mismatch**
```python
# package.json: 1.0.0
# lifecycle_manager.py: 1.0.1
# ZIP name: my-plugin-1.0.2.zip
# FIX: Make all three match!
```
❌ **Wrong scope in webpack**
```javascript
// plugin_slug: "MyPlugin"
// webpack scope: "DifferentScope" // WRONG!
```
❌ **Including node_modules**
```bash
# This makes ZIP huge!
# Always exclude node_modules
```
## Re-Packaging for Updates
When releasing a new version:
1. Update version in package.json, lifecycle_manager.py, changelog
2. Rebuild: `npm run build`
3. Create new ZIP: `{slug}-{new-version}.zip`
4. Keep old ZIP for version history
5. Update plugin manifest/changelog
---
Packaging is the final step. Get it right, and users can install your plugin with a single click.Related Skills
technical-accuracy-and-usability-rules
Ensures the documentation is technically accurate and highly usable for the target audience.
rules-migration
MIGRATE CLAUDE.md into modular `.claude/rules/` directory structure following Claude Code's rules system. Converts monolithic CLAUDE.md into organized, path-specific rule files with glob patterns. Use when migrating to rules system, modularizing project instructions, splitting CLAUDE.md, organizing memory files. Triggers on "migrate claudemd to rules", "convert claude.md to rules", "modularize claude.md", "split claude.md into rules", "migrate to rules system".
rules-eval
Evaluate and validate Claude Code rules in .claude/rules/ directories. Use when auditing rule file quality, validating frontmatter and glob patterns, or checking rules organization before deployment. Do not use when writing new rules from scratch - use rule authoring guides instead. Do not use when evaluating skills or hooks - use skills-eval or hooks-eval instead.
python-fastapi-scalable-api-cursorrules-prompt-fil-cursorrules
Apply for python-fastapi-scalable-api-cursorrules-prompt-fil. --- description: Applies general coding style and structure rules for Python code in the backend. globs: backend/src/**/*.py
prompt-generation-rules
General rules to generate prompt.
my-react-rules
This is a new rule
mobile-first-design-rules
Focuses on rules and best practices for mobile-first design and responsive typography using tailwind.
history-and-next-task-rules
Specifies the format for ending responses, including a summary of requirements, code written, source tree, and next task, applying to all files.
get-qodo-rules
Loads org- and repo-level coding rules from Qodo before code tasks begin, ensuring all generation and modification follows team standards. Use before any code generation or modification task when rules are not already loaded. Invoke when user asks to write, edit, refactor, or review code, or when starting implementation planning.
file-management-rules
Specifies file management guidelines, including including full file paths as comments, updating project structure in AI.MD, and maintaining package.json. This rule ensures organized and well-documente
eslint-rules
Use when eSLint built-in rules including rule configuration, severity levels, and disabling strategies.
editing-code-rules
Prioritizes the method for editing code and defines verbosity levels.