boundary-bbcr-fallback
Execute automatic BBCR (Collapse-Rebirth Correction) when knowledge boundaries are exceeded or reasoning fails.
Reduce and optimize bundle sizes
$ npx -y skills add qdhenry/Claude-Command-Suite --agent claude-codeHow it fires
How this command gets triggered: by you, by Claude, or both.
/optimize-bundle-sizeContext preview
What this command does when you run it.
Reduce and optimize bundle sizes
Reduce and optimize bundle sizes
1. **Bundle Analysis and Assessment**
2. **Build Tool Configuration**
**Webpack Configuration:**
// webpack.config.js
const path = require('path');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
module.exports = {
mode: 'production',
optimization: {
splitChunks: {
chunks: 'all',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
priority: 10,
reuseExistingChunk: true,
},
common: {
name: 'common',
minChunks: 2,
priority: 5,
reuseExistingChunk: true,
},
},
},
usedExports: true,
sideEffects: false,
},
plugins: [
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: false,
}),
],
};**Vite Configuration:**
// vite.config.js
import { defineConfig } from 'vite';
import { visualizer } from 'rollup-plugin-visualizer';
export default defineConfig({
build: {
rollupOptions: {
output: {
manualChunks: {
vendor: ['react', 'react-dom'],
ui: ['@mui/material', '@emotion/react'],
},
},
},
},
plugins: [
visualizer({
filename: 'dist/stats.html',
open: true,
gzipSize: true,
}),
],
});3. **Code Splitting and Lazy Loading**
**React Route Splitting:**
import { lazy, Suspense } from 'react';
import { Routes, Route } from 'react-router-dom';
const Home = lazy(() => import('./pages/Home'));
const Dashboard = lazy(() => import('./pages/Dashboard'));
const Profile = lazy(() => import('./pages/Profile'));
function App() {
return (
<Suspense fallback={<div>Loading...</div>}>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/dashboard" element={<Dashboard />} />
<Route path="/profile" element={<Profile />} />
</Routes>
</Suspense>
);
}**Dynamic Imports:**
// Lazy load heavy components
const HeavyComponent = lazy(() =>
import('./HeavyComponent').then(module => ({
default: module.HeavyComponent
}))
);
// Conditional loading
async function loadAnalytics() {
if (process.env.NODE_ENV === 'production') {
const { analytics } = await import('./analytics');
return analytics;
}
}4. **Tree Shaking and Dead Code Elimination**
**Package.json Configuration:**
{
"sideEffects": false,
"exports": {
".": {
"import": "./dist/index.esm.js",
"require": "./dist/index.cjs.js"
}
}
}**Import Optimization:**
// Instead of importing entire library
// import * as _ from 'lodash';
// Import only what you need
import debounce from 'lodash/debounce';
import throttle from 'lodash/throttle';
// Use babel-plugin-import for automatic optimization
// .babelrc
{
"plugins": [
["import", {
"libraryName": "lodash",
"libraryDirectory": "",
"camel2DashComponentName": false
}, "lodash"]
]
}5. **Dependency Optimization**
**Package Analysis Script:**
// scripts/analyze-deps.js
const fs = require('fs');
const path = require('path');
function analyzeDependencies() {
const packageJson = JSON.parse(
fs.readFileSync('package.json', 'utf8')
);
const deps = {
...packageJson.dependencies,
...packageJson.devDependencies
};
console.log('Large dependencies to review:');
Object.keys(deps).forEach(dep => {
try {
const depPath = require.resolve(dep);
const stats = fs.statSync(depPath);
if (stats.size > 100000) { // > 100KB
console.log(`${dep}: ${(stats.size / 1024).toFixed(2)}KB`);
}
} catch (e) {
// Skip if can't resolve
}
});
}
analyzeDependencies();6. **Asset Optimization**
**Image Optimization:**
// webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.(png|jpe?g|gif|svg)$/i,
use: [
{
loader: 'file-loader',
options: {
outputPath: 'images',
},
},
{
loader: 'image-webpack-loader',
options: {
mozjpeg: { progressive: true, quality: 80 },
optipng: { enabled: false },
pngquant: { quality: [0.6, 0.8] },
gifsicle: { interlaced: false },
},
},
],
},
],
},
};7. **Module Federation and Micro-frontends**
**Module Federation Setup:**
// webpack.config.js
const ModuleFederationPlugin = require('@module-federation/webpack');
module.exports = {
plugins: [
new ModuleFederationPlugin({A comprehensive development toolkit designed following Anthropic's Claude Code Best Practices for AI-assisted software development.
Repo: qdhenry/Claude-Command-Suite
Execute automatic BBCR (Collapse-Rebirth Correction) when knowledge boundaries are exceeded or reasoning fails.
Analyze semantic position relative to knowledge boundaries to prevent hallucination and identify uncertainty zones.
Generate a visual heatmap of knowledge boundaries showing safe zones, risk areas, and semantic coverage.
Evaluate the current risk level and provide detailed analysis of potential hallucination or reasoning failure.
Find and construct semantic bridges to safely navigate from current position to target concept without crossing dangerous boundaries.
Takes an input prompt and returns ONLY a token-optimized version that preserves meaning while minimizing token count. Based on LLM tokenization principles:…