PixelPilot: Instructions file for GitHub Copilot

vscode/.github/instructions/uiux-component-analytics.instructions.md

PixelPilot uiux-component-analytics.instructions.md is an instructions file for GitHub Copilot from dev-lou/PixelPilot. It costs 3,558 tokens per session, scanned A, original, MIT.

A codebase scanner for React, Vue, and Svelte components. It counts imports and uses, flags unused components, measures complexity, and suggests optimizations.

In plain words
What is it for?
Use it to review component usage, find code that may be removable, identify complex components, and export the results as JSON.
Why use it?
It shows which components are central, neglected, or unnecessarily complicated, so you can focus cleanup and reuse work where it matters.

Instructions file for GitHub Copilot

Written for GitHub Copilot: a Copilot instructions file. Also seen: mentions OpenCode.

This is dev-lou/PixelPilot's own configuration. It tells GitHub Copilot how to work on PixelPilot itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything PixelPilot configures →

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is node .opencode/rules/uiux-component-analytics.js ./src --json > analytics.json.

Reuse

Borrowing it

Nothing to install: this file belongs to dev-lou/PixelPilot. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/dev-lou/PixelPilot/main/vscode/.github/instructions/uiux-component-analytics.instructions.md
Clone the repo
git clone --depth 1 https://github.com/dev-lou/PixelPilot

Made for: GitHub Copilot.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for PixelPilot uiux-component-analytics.instructions.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/dev-lou/pixelpilot/uiux-component-analytics/github.svg)](https://agentmods.dev/instructions/dev-lou/pixelpilot/uiux-component-analytics)
Your own site
<a href="https://agentmods.dev/instructions/dev-lou/pixelpilot/uiux-component-analytics"><img src="https://agentmods.dev/badge/instructions/dev-lou/pixelpilot/uiux-component-analytics/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for PixelPilot uiux-component-analytics.instructions.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/dev-lou/pixelpilot/uiux-component-analytics"><img src="https://agentmods.dev/badge/instructions/dev-lou/pixelpilot/uiux-component-analytics.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 3,558 This file is loaded in full into every session.
When invoked 3,558 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.03558 $0.03558
Opus 5.5 $0.01423 $0.01423
Sonnet 5.5 $0.00712 $0.00712
Haiku 4.5 $0.00356 $0.00356

Measured 2mo ago against content hash 798840832b0e, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

PixelPilot uiux-component-analytics.instructions.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

vscode/.github/instructions/uiux-component-analytics.instructions.md · 511 lines

How it starts

The opening of the file, as written. The whole thing — 511 lines — stays where its author put it; the contents beside it link to each section on GitHub.

UI/UX Component Analytics Skill

Analyse your codebase to understand component usage patterns. Identify optimization opportunities and unused code.


OVERVIEW

This skill scans your codebase to:

  1. Count component imports and usages
  2. Identify most/least used components
  3. Calculate complexity scores
  4. Detect unused components
  5. Suggest optimizations

USAGE

Command Line

# Run the analyzer
node uiux-component-analytics.js ./src

# Output to JSON
node uiux-component-analytics.js ./src --json > report.json

# Include complexity analysis
node uiux-component-analytics.js ./src --complexity

AI Prompt

Analyze the component usage in this codebase. Tell me:
1. Which components are used most frequently?
2. Are there any unused components I can remove?
3. Which components are overly complex?
4. What optimization opportunities exist?

ANALYZER SCRIPT

#!/usr/bin/env node

/**
 * Component Analytics Analyzer
 * Scans codebase for React/Vue/Svelte component usage patterns
 */

const fs = require('fs');
const path = require('path');

const CONFIG = {
  extensions: ['.jsx', '.tsx', '.vue', '.svelte', '.js', '.ts'],
  skipDirs: ['node_modules', '.git', 'dist', 'build', '.next'],
  componentPatterns: {
    // React/JSX components (PascalCase)
    react: /<([A-Z][a-zA-Z0-9]+)(?:\s|\/|>)/g,
    // Import statements
    imports: /import\s+(?:{[^}]+}|\w+)\s+from\s+['"]([^'"]+)['"]/g,
    // React.lazy imports
    lazy: /React\.lazy\s*\(\s*\(\)\s*=>\s*import\s*\(['"]([^'"]+)['"]\)\s*\)/g,
  }
};

// Component registry
const components = new Map();
const imports = new Map();
const fileComplexity = new Map();

function walkDir(dir, callback) {
  if (!fs.existsSync(dir)) return;
  
  const files = fs.readdirSync(dir);
  
  for (const file of files) {
    const filePath = path.join(dir, file);
    const stat = fs.statSync(filePath);
    
    if (stat.isDirectory()) {
      if (!CONFIG.skipDirs.includes(file)) {
        walkDir(filePath, callback);
      }
    } else {
      const ext = path.extname(file);
      if (CONFIG.extensions.includes(ext)) {
        callback(filePath);
      }
    }
  }
}

function analyzeFile(filePath) {
  const content = fs.readFileSync(filePath, 'utf8');
  
  // Track JSX component usage
  let match;
  while ((match = CONFIG.componentPatterns.react.exec(content)) !== null) {
    const componentName = match[1];
    
    // Skip HTML elements
    if (componentName === componentName.toLowerCase()) continue;
    
    if (!components.has(componentName)) {
      components.set(componentName, {
        name: componentName,
        usages: [],
        importedFrom: null,
        isExported: false
      });
    }
    
    components.get(componentName).usages.push({
      file: filePath,
      line: getLineNumber(content, match.index)
    });
  }
  
  // Track imports
  while ((match = CONFIG.componentPatterns.imports.exec(content)) !== null) {
    const importPath = match[1];
    const importStatement = match[0];
    
    // Extract component names from import
    const namedImports = importStatement.match(/{\s*([^}]+)\s*}/);
    if (namedImports) {
      namedImports[1].split(',').forEach(name => {
        const cleanName = name.trim().split(' as ')[0].trim();
        if (cleanName && /^[A-Z]/.test(cleanName)) {
          if (components.has(cleanName)) {
            components.get(cleanName).importedFrom = importPath;
          }
        }
      });
    }
    
    // Track import counts
    if (!imports.has(importPath)) {
      imports.set(importPath, { count: 0, files: [] });
    }
    imports.get(importPath).count++;
    imports.get(importPath).files.push(filePath);
  }
  
  // Calculate complexity
  const complexity = calculateComplexity(content, filePath);
  fileComplexity.set(filePath, complexity);
}

function getLineNumber(content, index) {
  return content.substring(0, index).split('\n').length;
}

function calculateComplexity(content, filePath) {
  let score = 0;
  const factors = [];
  
  // Lines of code
  const lines = content.split('\n').length;
  if (lines > 300) {
    score += 2;
    factors.push(`Large file (${lines} lines)`);
  } else if (lines > 150) {
    score += 1;
    factors.push(`Medium file (${lines} lines)`);
  }
  
  // Number of hooks (React)
  const hooks = (content.match(/use[A-Z]\w+/g) || []).length;
  if (hooks > 10) {
    score += 3;
    factors.push(`Many hooks (${hooks})`);
  } else if (hooks > 5) {
    score += 1;
    factors.push(`Several hooks (${hooks})`);
  }
  
  // Number of state variables
  const stateCount = (content.match(/useState/g) || []).length;
  if (stateCount > 7) {
    score += 2;
    factors.push(`Many state variables (${stateCount})`);
  }
  
  // Nested ternaries
  const nestedTernaries = (content.match(/\?.*\?.*:/g) || []).length;
  if (nestedTernaries > 0) {
    score += nestedTernaries;
    factors.push(`Nested ternaries (${nestedTernaries})`);
  }
  
  // Inline styles (anti-pattern)
  const inlineStyles = (content.match(/style=\{\{/g) || []).length;
  if (inlineStyles > 5) {
    score += 1;
    factors.push(`Many inline styles (${inlineStyles})`);
  }
  
  // Props spreading (potential issue)
  const propsSpreading = (content.match(/\{\.\.\.props\}/g) || []).length;
  if (propsSpreading > 0) {
    factors.push(`Props spreading (${propsSpreading})`);
  }
  
  return {
    score,
    factors,
    lines
  };
}

function generateReport(targetDir, outputJson = false) {
  // Sort by usage count
  const sortedComponents = Array.from(components.entries())
    .map(([name, data]) => ({
      name,
      usageCount: data.usages.length,
      importedFrom: data.importedFrom,
      usedIn: [...new Set(data.usages.map(u => u.file))]
    }))
    .sort((a, b) => b.usageCount - a.usageCount);
  
  // High complexity files
  const complexFiles = Array.from(fileComplexity.entries())
    .map(([file, data]) => ({
      file: path.relative(targetDir, file),
      ...data
    }))
    .filter(f => f.score >= 3)
    .sort((a, b) => b.score - a.score);
  
  // Unused components (0 usages found)
  const potentiallyUnused = sortedComponents.filter(c => c.usageCount === 1);
  
  // Most imported packages
  const topImports = Array.from(imports.entries())
    .map(([pkg, data]) => ({ package: pkg, ...data }))
    .sort((a, b) => b.count - a.count)
    .slice(0, 20);
  
  const report = {
    summary: {
      totalComponents: components.size,
      totalFiles: fileComplexity.size,
      highComplexityFiles: complexFiles.length,
      potentiallyUnusedComponents: potentiallyUnused.length
    },
    mostUsedComponents: sortedComponents.slice(0, 15),
    leastUsedComponents: sortedComponents.slice(-10).reverse(),
    potentiallyUnused,
    highComplexityFiles: complexFiles.slice(0, 10),
    topImports: topImports.slice(0, 10),
    optimizationSuggestions: generateSuggestions(sortedComponents, complexFiles)
  };
  
  if (outputJson) {
    console.log(JSON.stringify(report, null, 2));
  } else {
    printReport(report);
  }
  
  return report;
}

function generateSuggestions(components, complexFiles) {
  const suggestions = [];
  
  // Split large components
  complexFiles.forEach(f => {
    if (f.lines > 300) {
      suggestions.push({
        type: 'split-component',
        file: f.file,
        reason: `File has ${f.lines} lines. Consider splitting into smaller components.`,
        priority: 'medium'
      });
    }
  });
  
  // Consolidate rarely used components
  const rareComponents = components.filter(c => c.usageCount === 1 && c.usedIn.length === 1);
  if (rareComponents.length > 5) {
    suggestions.push({
      type: 'consolidate',
      reason: `${rareComponents.length} components are only used once. Consider inlining or consolidating.`,
      components: rareComponents.map(c => c.name).slice(0, 10),
      priority: 'low'
    });
  }
  
  // Highly used components should be optimized
  const highlyUsed = components.filter(c => c.usageCount > 50);
  highlyUsed.forEach(c => {
    suggestions.push({
      type: 'optimize-frequent',
      component: c.name,
      reason: `Used ${c.usageCount} times. Ensure it's memoized (React.memo) and optimized.`,
      priority: 'high'
    });
  });
  
  return suggestions;
}

function printReport(report) {
  console.log('\n╔════════════════════════════════════════════════════════════╗');
  console.log('║           COMPONENT ANALYTICS REPORT                       ║');
  console.log('╚════════════════════════════════════════════════════════════╝\n');
  
  console.log('📊 Summary');
  console.log('─'.repeat(50));
  console.log(`   Total components found: ${report.summary.totalComponents}`);
  console.log(`   Files analyzed: ${report.summary.totalFiles}`);
  console.log(`   High complexity files: ${report.summary.highComplexityFiles}`);
  console.log(`   Potentially unused: ${report.summary.potentiallyUnusedComponents}`);
  
  console.log('\n🔥 Most Used Components');
  console.log('─'.repeat(50));
  report.mostUsedComponents.slice(0, 10).forEach((c, i) => {
    console.log(`   ${i + 1}. ${c.name} (${c.usageCount} usages)`);
  });
  
  console.log('\n❄️  Least Used Components');
  console.log('─'.repeat(50));
  report.leastUsedComponents.slice(0, 5).forEach((c, i) => {
    console.log(`   ${i + 1}. ${c.name} (${c.usageCount} usages)`);
  });
  
  if (report.highComplexityFiles.length > 0) {
    console.log('\n⚠️  High Complexity Files');
    console.log('─'.repeat(50));
    report.highComplexityFiles.slice(0, 5).forEach(f => {
      console.log(`   ${f.file}`);
      console.log(`      Score: ${f.score}, Lines: ${f.lines}`);
      console.log(`      Factors: ${f.factors.join(', ')}`);
    });
  }
  
  if (report.optimizationSuggestions.length > 0) {
    console.log('\n💡 Optimization Suggestions');
    console.log('─'.repeat(50));
    report.optimizationSuggestions.forEach((s, i) => {
      const icon = s.priority === 'high' ? '🔴' : s.priority === 'medium' ? '🟡' : '🟢';
      console.log(`   ${icon} ${s.reason}`);
    });
  }
  
  console.log('\n');
}

// Main execution
const args = process.argv.slice(2);
const targetDir = args.find(a => !a.startsWith('--')) || './src';
const outputJson = args.includes('--json');

console.log(`Analyzing: ${path.resolve(targetDir)}\n`);
walkDir(targetDir, analyzeFile);
generateReport(targetDir, outputJson);

Read the full file on GitHub · 511 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago First seen · 511 lines · 3,558 tokens per session scan A 798840832b0e

Subscribe to this mod's changes

PixelPilot uiux-component-analytics.instructions.md is an instructions file published in the GitHub repository dev-lou/PixelPilot (2 stars, last pushed 7mo ago), licensed MIT. It adds 3,558 tokens to every session, about $0.0142 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

PixelPilot uiux-component-analytics.instructions.md compared with instructions from other repositories

PixelPilot uiux-component-analytics.instructions.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
PixelPilot uiux-component-analytics.instructions.mddev-lou/PixelPilotInstructions file27mo agoMITA3,558GitHub Copilot
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143ktodayMITA7,461Codex, OpenCode
langchain AGENTS.mdlangchain-ai/langchainInstructions file149kyesterdayMITA4,680Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA5,516GitHub Copilot
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA3,093GitHub Copilot
deepseek-harness AGENTS.mddeepseek-ai/deepseek-harnessInstructions file274k2d agoMITA4,313Codex, OpenCode