boundary-bbcr-fallback
Execute automatic BBCR (Collapse-Rebirth Correction) when knowledge boundaries are exceeded or reasoning fails.
Setup application performance monitoring
$ npx -y skills add qdhenry/Claude-Command-Suite --agent claude-codeHow it fires
How this command gets triggered: by you, by Claude, or both.
/add-performance-monitoringContext preview
What this command does when you run it.
Setup application performance monitoring
Setup application performance monitoring
1. **Performance Monitoring Strategy**
2. **Application Performance Monitoring (APM)**
**Node.js APM with New Relic:**
// newrelic.js
exports.config = {
app_name: [process.env.NEW_RELIC_APP_NAME || 'My Application'],
license_key: process.env.NEW_RELIC_LICENSE_KEY,
distributed_tracing: {
enabled: true
},
transaction_tracer: {
enabled: true,
transaction_threshold: 0.5, // 500ms
record_sql: 'obfuscated',
explain_threshold: 1000 // 1 second
},
error_collector: {
enabled: true,
ignore_status_codes: [404, 401]
},
browser_monitoring: {
enable: true
},
application_logging: {
forwarding: {
enabled: true
}
}
};
// app.js
require('newrelic');
const express = require('express');
const app = express();
// Custom metrics
const newrelic = require('newrelic');
app.use((req, res, next) => {
const startTime = Date.now();
res.on('finish', () => {
const duration = Date.now() - startTime;
// Record custom metrics
newrelic.recordMetric('Custom/ResponseTime', duration);
newrelic.recordMetric(`Custom/Endpoint/${req.path}`, duration);
// Add custom attributes
newrelic.addCustomAttributes({
'user.id': req.user?.id,
'request.method': req.method,
'response.statusCode': res.statusCode
});
});
next();
});**Datadog APM Integration:**
// datadog-tracer.js
const tracer = require('dd-trace').init({
service: 'my-application',
env: process.env.NODE_ENV,
version: process.env.APP_VERSION,
logInjection: true,
runtimeMetrics: true,
profiling: true,
analytics: true
});
// Custom instrumentation
class PerformanceTracker {
static startSpan(operationName, options = {}) {
return tracer.startSpan(operationName, {
tags: {
'service.name': 'my-application',
...options.tags
},
...options
});
}
static async traceAsync(operationName, asyncFn, tags = {}) {
const span = this.startSpan(operationName, { tags });
try {
const result = await asyncFn(span);
span.setTag('operation.success', true);
return result;
} catch (error) {
span.setTag('operation.success', false);
span.setTag('error.message', error.message);
span.setTag('error.stack', error.stack);
throw error;
} finally {
span.finish();
}
}
static trackDatabaseQuery(query, duration, success) {
tracer.startSpan('database.query', {
tags: {
'db.statement': query,
'db.duration': duration,
'db.success': success
}
}).finish();
}
}
// Usage example
app.get('/api/users/:id', async (req, res) => {
await PerformanceTracker.traceAsync('get_user', async (span) => {
span.setTag('user.id', req.params.id);
const user = await getUserFromDatabase(req.params.id);
span.setTag('user.found', !!user);
res.json(user);
}, { endpoint: '/api/users/:id' });
});3. **Real User Monitoring (RUM)**
**Web Vitals Monitoring:**
// performance-monitor.js
import { getCLS, getFID, getFCP, getLCP, getTTFB } from 'web-vitals';
class RealUserMonitoring {
constructor() {
this.metrics = {};
this.setupWebVitals();
this.setupCustomMetrics();
}
setupWebVitals() {
getCLS(this.sendMetric.bind(this, 'CLS'));
getFID(this.sendMetric.bind(this, 'FID'));
getFCP(this.sendMetric.bind(this, 'FCP'));
getLCP(this.sendMetric.bind(this, 'LCP'));
getTTFB(this.sendMetric.bind(this, 'TTFB'));
}
setupCustomMetrics() {
// Track page load performance
window.addEventListener('load', () => {
const navigation = performance.getEntriesByType('navigation')[0];
this.sendMetric('page_load_time', {
name: 'page_load_time',
value: navigation.loadEventEnd - navigation.fetchStart,
delta: navigation.loadEventEnd - navigation.fetchStart
});
this.sendMetric('dom_content_loaded', {
name: 'dom_content_loaded',
value: navigation.domContentLoadedEventEnd - navigation.fetchStart,
delta: navigation.domContentLoadedEventEnd - navigation.fetchStart
});
});
// Track resource loading
new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
if (entry.duration > 1000) { // Resources taking >1s
this.sendMetric('slow_resource', {
name: 'slow_resource',
value: entry.duration,
resource: entry.name,
type: entry.initiatorType
});
}
}
}).observe({ entryTypes: ['resource'] });
// Track user interactions
['click', 'keydown', 'touchstart'].forEach(eventType => {
document.addEventListener(eventType, (event) => {
const startTime = performance.now();
requestIdleCallback(() => {
const duration = performance.now() - startTime;
if (duration > 100) { // IA 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:…