Skip to content
Back to search

awesome-claude-plugins

A curated list of Plugins that let you extend Claude Code with custom commands, agents, hooks, and MCP servers through the plugin system.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/composio-community-awesome-claude-plugins/badge.svg)](/listings/composio-community-awesome-claude-plugins)

HTML

<a href="/listings/composio-community-awesome-claude-plugins"><img src="/api/listings/composio-community-awesome-claude-plugins/badge.svg" alt="findsafeskills safety rating" /></a>

Install

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

/connect-apps:setup

Paste your API key when asked. (Get a free key at [dashboard.composio.dev](https://dashboard.composio.dev/login?utm_source=Github&utm_medium=Banner&utm_content=AwesomePlugins)

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

.claude-plugin/marketplace.json · Manifest · 254 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. {
  2. "name": "awesome-claude-plugins",
  3. "owner": {
  4. "name": "Composio",
  5. "email": "support@composio.dev"
  6. },
  7. "metadata": {
  8. "description": "A curated marketplace of production-ready plugins for Claude Code",
  9. "version": "1.0.0",
  10. "pluginRoot": "./"
  11. },
  12. "plugins": [
  13. {
  14. "name": "connect-apps",
  15. "source": "./connect-apps",
  16. "description": "Connect Claude to 500+ apps - Gmail, Slack, GitHub, Notion, and more",
  17. "category": "integrations",
  18. "tags": ["integrations", "oauth", "gmail", "slack", "github", "notion"],
  19. "author": {
  20. "name": "Composio"
  21. }
  22. },
  23. {
  24. "name": "frontend-design",
  25. "source": "./frontend-design",
  26. "description": "Create distinctive, production-grade interfaces avoiding generic AI aesthetics",
  27. "category": "frontend",
  28. "tags": ["frontend", "design", "ui", "css", "react"],
  29. "author": {
  30. "name": "Anthropic"
  31. }
  32. },
  33. {
  34. "name": "artifacts-builder",
  35. "source": "./artifacts-builder",
  36. "description": "Build complex HTML artifacts with React, Tailwind CSS, and shadcn/ui",
  37. "category": "frontend",
  38. "tags": ["frontend", "react", "tailwind", "shadcn", "artifacts"],
  39. "author": {
  40. "name": "Composio"
  41. }
  42. },
  43. {
  44. "name": "theme-factory",
  45. "source": "./theme-factory",
  46. "description": "10 professional themes for slides, docs, reports, and landing pages",
  47. "category": "frontend",
  48. "tags": ["design", "themes", "styling", "branding"],
  49. "author": {
  50. "name": "Composio"
  51. }
  52. },
  53. {
  54. "name": "canvas-design",
  55. "source": "./canvas-design",
  56. "description": "Create museum-quality visual art in PNG and PDF formats",
  57. "category": "frontend",
  58. "tags": ["design", "art", "visual", "pdf", "png"],
  59. "author": {
  60. "name": "Composio"
  61. }
  62. },
  63. {
  64. "name": "senior-frontend",
  65. "source": "./senior-frontend",
  66. "description": "React/Next.js/TypeScript patterns with bundle analysis and optimization",
  67. "category": "frontend",
  68. "tags": ["frontend", "react", "nextjs", "typescript", "performance"],
  69. "author": {
  70. "name": "alirezarezvani"
  71. }
  72. },
  73. {
  74. "name": "frontend-developer",
  75. "source": "./frontend-developer",
  76. "description": "Frontend development specialist agent",
  77. "category": "frontend",
  78. "tags": ["frontend", "agent", "development"],
  79. "author": {
  80. "name": "Community"
  81. }
  82. },
  83. {
  84. "name": "commit",
  85. "source": "./commit",
  86. "description": "Smart git commits using conventional commit format",
  87. "category": "git",
  88. "tags": ["git", "commits", "conventional-commits"],
  89. "author": {
  90. "name": "Community"
  91. }
  92. },
  93. {
  94. "name": "create-pr",
  95. "source": "./create-pr",
  96. "description": "Automates pull request creation with proper templates",
  97. "category": "git",
  98. "tags": ["git", "pull-request", "github"],
  99. "author": {
  100. "name": "Community"
  101. }
  102. },
  103. {
  104. "name": "pr-review",
  105. "source": "./pr-review",
  106. "description": "Comprehensive PR reviews with detailed feedback",
  107. "category": "git",
  108. "tags": ["git", "code-review", "pull-request"],
  109. "author": {
  110. "name": "Community"
  111. }
  112. },
  113. {
  114. "name": "changelog-generator",
  115. "source": "./changelog-generator",
  116. "description": "Transform git commits into user-friendly changelogs",
  117. "category": "git",
  118. "tags": ["git", "changelog", "release-notes"],
  119. "author": {
  120. "name": "Composio"
  121. }
  122. },
  123. {
  124. "name": "ship",
  125. "source": "./ship",
  126. "description": "Complete PR workflow from commit to production",
  127. "category": "git",
  128. "tags": ["git", "workflow", "deployment", "ci-cd"],
  129. "author": {
  130. "name": "Community"
  131. }
  132. },
  133. {
  134. "name": "code-review",
  135. "source": "./code-review",
  136. "description": "Comprehensive code review with best practices",
  137. "category": "quality",
  138. "tags": ["code-review", "quality", "best-practices"],
  139. "author": {
  140. "name": "Community"
  141. }
  142. },
  143. {
  144. "name": "test-writer-fixer",
  145. "source": "./test-writer-fixer",
  146. "description": "Automatically write and fix unit tests",
  147. "category": "quality",
  148. "tags": ["testing", "unit-tests", "jest", "vitest"],
  149. "author": {
  150. "name": "Community"
  151. }
  152. },
  153. {
  154. "name": "debugger",
  155. "source": "./debugger",
  156. "description": "Advanced debugging assistant",
  157. "category": "quality",
  158. "tags": ["debugging", "troubleshooting"],
  159. "author": {
  160. "name": "Community"
  161. }
  162. },
  163. {
  164. "name": "bug-fix",
  165. "source": "./bug-fix",
  166. "description": "Analyzes and fixes bugs in your codebase",
  167. "category": "quality",
  168. "tags": ["debugging", "bug-fix", "troubleshooting"],
  169. "author": {
  170. "name": "Community"
  171. }
  172. },
  173. {
  174. "name": "backend-architect",
  175. "source": "./backend-architect",
  176. "description": "Backend architecture patterns and system design",
  177. "category": "backend",
  178. "tags": ["backend", "architecture", "api", "database"],
  179. "author": {
  180. "name": "Community"
  181. }
  182. },
  183. {
  184. "name": "mcp-builder",
  185. "source": "./mcp-builder",
  186. "description": "Build high-quality MCP servers for LLM integrations",
  187. "category": "backend",
  188. "tags": ["mcp", "servers", "integrations", "python", "typescript"],
  189. "author": {
  190. "name": "Composio"
  191. }
  192. },
  193. {
  194. "name": "agent-sdk-dev",
  195. "source": "./agent-sdk-dev",
  196. "description": "Claude Agent SDK development helper",
  197. "category": "backend",
  198. "tags": ["agent-sdk", "agents", "development"],
  199. "author": {
  200. "name": "Community"
  201. }
  202. },
  203. {
  204. "name": "perf",
  205. "source": "./perf",
  206. "description": "Performance analysis and optimization",
  207. "category": "devops",
  208. "tags": ["performance", "optimization", "profiling"],
  209. "author": {
  210. "name": "Community"
  211. }
  212. },
  213. {
  214. "name": "audit-project",
  215. "source": "./audit-project",
  216. "description": "Full project audit for quality and issues",
  217. "category": "devops",
  218. "tags": ["audit", "quality", "dependencies", "security"],
  219. "author": {
  220. "name": "Community"
  221. }
  222. },
  223. {
  224. "name": "documentation-generator",
  225. "source": "./documentation-generator",
  226. "description": "Generate comprehensive documentation from code",
  227. "category": "docs",
  228. "tags": ["documentation", "readme", "api-docs"],
  229. "author": {
  230. "name": "Community"
  231. }
  232. },
  233. {
  234. "name": "security-guidance",
  235. "source": "./security-guidance",
  236. "description": "Security best practices and vulnerability detection",
  237. "category": "security",
  238. "tags": ["security", "owasp", "vulnerabilities"],
  239. "author": {
  240. "name": "Community"
  241. }
  242. },
  243. {
  244. "name": "developer-growth-analysis",
  245. "source": "./developer-growth-analysis",
  246. "description": "Analyze coding patterns and get personalized learning resources",
  247. "category": "productivity",
  248. "tags": ["productivity", "learning", "growth", "analytics"],
  249. "author": {
  250. "name": "Composio"
  251. }
  252. }
  253. ]
  254. }
README.md · README · 236 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. <h1 align="center">Awesome Claude Code Plugins</h1>
  2. <p align="center">
  3. <a href="https://dashboard.composio.dev/login?utm_source=Github&utm_medium=Banner&utm_content=AwesomePlugins">
  4. <img width="1280" alt="Awesome Claude Plugins" src="./cover_image.png">
  5. </a>
  6. </p>
  7. <p align="center">
  8. <a href="https://awesome.re">
  9. <img src="https://awesome.re/badge.svg" alt="Awesome" />
  10. </a>
  11. <a href="https://makeapullrequest.com">
  12. <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square" alt="PRs Welcome" />
  13. </a>
  14. <a href="https://opensource.org/licenses/MIT">
  15. <img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square" alt="License: MIT" />
  16. </a>
  17. </p>
  18. <div>
  19. <p align="center">
  20. <a href="https://twitter.com/composio">
  21. <img src="https://img.shields.io/badge/Follow%20on%20X-000000?style=for-the-badge&logo=x&logoColor=white" alt="Follow on X" />
  22. </a>
  23. <a href="https://www.linkedin.com/company/composiohq/">
  24. <img src="https://img.shields.io/badge/Follow%20on%20LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white" alt="Follow on LinkedIn" />
  25. </a>
  26. <a href="https://discord.com/invite/composio">
  27. <img src="https://img.shields.io/badge/Join%20our%20Discord-5865F2?style=for-the-badge&logo=discord&logoColor=white" alt="Join our Discord" />
  28. </a>
  29. </p>
  30. </div>
  31. <p align="center">
  32. A curated list of production-ready plugins for Claude Code to supercharge your development workflow.
  33. </p>
  34. > **Want plugins that do more than generate text?** The [connect-apps](./connect-apps) plugin lets Claude send emails, create issues, post to Slack, and take actions across 1000+ apps.
  35. ---
  36. ## Give your skills real-world actions
  37. Skills tell your agent **how** to work. An MCP Gateway gives it secure access to the tools it needs.
  38. Composio [MCP Gateway](https://composio.dev/mcp-gateway) provides a single MCP endpoint for 1,000+ integrations with built-in authentication, team-based access controls, audit logs, and production-ready reliability.
  39. ### 1. Clone & Run
  40. ```bash
  41. git clone https://github.com/composiohq/awesome-claude-plugins.git
  42. cd awesome-claude-plugins
  43. claude --plugin-dir ./connect-apps
  44. ```
  45. ### 2. Run Setup
  46. ```shell
  47. /connect-apps:setup
  48. ```
  49. Paste your API key when asked. (Get a free key at [dashboard.composio.dev](https://dashboard.composio.dev/login?utm_source=Github&utm_medium=Banner&utm_content=AwesomePlugins)
  50. ### 3. Try It
  51. Ask Claude to send you a test email. If you receive it, Claude is now connected to 1000+ apps.
  52. **[See all supported apps →](https://composio.dev/tools)**
  53. ---
  54. ## Contents
  55. - [What Are Claude Plugins?](#what-are-claude-plugins)
  56. - [Plugins](#plugins)
  57. - [Integrations](#integrations)
  58. - [Frontend & Design](#frontend--design)
  59. - [Git & Version Control](#git--version-control)
  60. - [Code Quality & Testing](#code-quality--testing)
  61. - [Agent Memory](#agent-memory)
  62. - [Backend & Architecture](#backend--architecture)
  63. - [DevOps & Performance](#devops--performance)
  64. - [Documentation & Security](#documentation--security)
  65. - [Developer Productivity](#developer-productivity)
  66. - [Companion & Personality](#companion--personality)
  67. - [Getting Started](#getting-started)
  68. - [Contributing](#contributing)
  69. - [Resources](#resources)
  70. - [License](#license)
  71. ## What Are Claude Plugins?
  72. Claude Plugins are extensions that enhance Claude Code with custom slash commands, specialized agents, hooks, and skills. Plugins can be shared across projects and teams, providing consistent tooling and workflows.
  73. ## Plugins
  74. ### Integrations
  75. - [connect-apps](./connect-apps) - Connect Claude to any app. Send emails, create issues, post messages, update databases - take real actions across Gmail, Slack, GitHub, Notion, and 1000+ services.
  76. - [kaggle-skill](https://github.com/shepsci/kaggle-skill) - Complete Kaggle integration — account setup, competition reports, dataset/model downloads, notebook execution, submissions, and badge collection.
  77. ### Frontend & Design
  78. - [frontend-design](./frontend-design) - Create distinctive, production-grade interfaces. Avoids generic "AI slop" with bold typography, unique color palettes, and creative layouts.
  79. - [artifacts-builder](./artifacts-builder) - Suite of tools for creating elaborate, multi-component HTML artifacts using React, Tailwind CSS, and shadcn/ui.
  80. - [theme-factory](./theme-factory) - Applies professional font and color themes to artifacts including slides, docs, reports, and HTML landing pages with 10 pre-set themes.
  81. - [canvas-design](./canvas-design) - Creates beautiful visual art in PNG and PDF documents using design philosophy and aesthetic principles for posters and static pieces.
  82. - [senior-frontend](./senior-frontend) - React/Next.js/TypeScript development patterns with bundle analysis, component generation, and accessibility best practices.
  83. - [frontend-developer](./frontend-developer) - Frontend development specialist agent for building modern web interfaces.
  84. ### Git & Version Control
  85. - [commit](./commit) - Creates smart git commits using conventional commit format with meaningful messages and emojis.
  86. - [create-pr](./create-pr) - Automates pull request creation with proper templates, descriptions, and labels.
  87. - [pr-review](./pr-review) - Comprehensive PR reviews with detailed feedback on code quality, security, and best practices.
  88. - [changelog-generator](./changelog-generator) - Automatically creates user-facing changelogs from git commits by analyzing history and transforming technical commits into customer-friendly release notes.
  89. - [ship](./ship) - Complete PR workflow from commit to production. Lint, test, review, and deploy.
  90. ### Code Quality & Testing
  91. - [AgentLint](https://github.com/0xmariowu/AgentLint) - Lint your repo for AI agent compatibility. 33 evidence-backed checks across 5 dimensions. Claude Code plugin.
  92. - [code-review](./code-review) - Comprehensive code review with best practices, patterns, and improvement suggestions.
  93. - [test-writer-fixer](./test-writer-fixer) - Automatically write and fix unit tests. Supports Jest, Vitest, Pytest, and more.
  94. - [debugger](./debugger) - Advanced debugging assistant for tracking down and fixing complex bugs.
  95. - [bug-fix](./bug-fix) - Analyzes stack traces and code to identify and fix bugs in your codebase.
  96. ### Agent Memory
  97. - [glen](https://github.com/Glen-Web-App/glen-claude-code-plugin) - Shared team memory for coding agents. Recalls past decisions on every turn and records what you build, so your whole team's agents work from one history. ([Website](https://tryglen.com))
  98. ### Backend & Architecture
  99. - [backend-architect](./backend-architect) - Backend architecture patterns, API design, database schemas, and system design.
  100. - [mcp-builder](./mcp-builder) - Guides creation of high-quality MCP (Model Context Protocol) servers for integrating external APIs and services with LLMs.
  101. - [agent-sdk-dev](./agent-sdk-dev) - Claude Agent SDK development helper for building custom AI agents.
  102. - [maestro-orchestrate](https://github.com/josstei/maestro-orchestrate) - Multi-agent development orchestration coordinating 22 specialized subagents through 4-phase workflows with native parallel execution, persistent sessions, and standalone commands for code review, debugging, security audit, and more.
  103. ### DevOps & Performance
  104. - [perf](./perf) - Performance analysis and optimization. Identify bottlenecks and improve speed.
  105. - [audit-project](./audit-project) - Full project audit for code quality, dependencies, security, and best practices.
  106. - [MyVibe](https://www.myvibe.so) - Instant deployment to live URLs with `/myvibe:publish`.
  107. - [aws-cost-saver](https://github.com/prajapatimehul/aws-cost-saver) - Automated AWS cost optimization with 173 checks across EC2, RDS, S3, Lambda, and more. ML-powered recommendations and real pricing from AWS API.
  108. - [Manifest](https://github.com/mnfst/manifest) - Real-time cost observability for OpenClaw agents — track tokens, costs, messages, and model usage. Includes Claude Code [skill](https://github.com/mnfst/manifest/blob/main/skills/manifest/SKILL.md) for guided setup. Self-hosted, OTLP ingestion, 28+ LLM models. ([Website](https://manifest.build))
  109. ### Documentation & Security
  110. - [documentation-generator](./documentation-generator) - Generate comprehensive documentation from code. READMEs, API docs, and guides.
  111. - [security-guidance](./security-guidance) - Security best practices and vulnerability detection. OWASP guidelines and secure coding.
  112. - [security-sweep](https://github.com/Onome-AJ/security-sweep-plugin) - Comprehensive security scanner covering OWASP Top 10 (2025), Mobile Top 10 (2024), and LLM Top 10 (2025). Scans for hardcoded secrets, injection flaws, auth issues, misconfigurations, and AI-specific vulnerabilities.
  113. - [asqav-claude-code](https://github.com/jagmarques/asqav-claude-code) - Signs a tamper-evident Asqav receipt at the end of each Claude Code session: files edited (content hashes before/after), commands run (hashed), and git context. Verifiable by anyone at asqav.com/verify.
  114. ### Developer Productivity
  115. - [CCHub](https://github.com/Moresl/cchub) - Desktop app for managing the Claude Code ecosystem — MCP marketplace, config profiles, skills & plugins browser, workflow templates, security audit. Built with Tauri v2 + React + Rust.
  116. - [developer-growth-analysis](./developer-growth-analysis) - Analyzes your recent Claude Code chat history to identify coding patterns, development gaps, and curates personalized learning resources.
  117. - [skill-bus](./skill-bus) - The skill for connecting skills. Wire context, conditions, and other skills into any skill invocation — declaratively, without modification. Zero dependencies.
  118. - [context-mode](https://github.com/mksglu/claude-context-mode) - Process large outputs in sandboxed subprocesses, keeping only summaries in the context window. 98% context savings across 21 benchmarked scenarios.
  119. - [codebase-graph](https://github.com/Phoenixrr2113/codebase-graph) - Code intelligence MCP server that builds knowledge graphs from source code with 42-language tree-sitter AST parsing and FalkorDB.
  120. - [agntk](https://github.com/Phoenixrr2113/agntk) - Zero-config AI agent CLI with persistent named agents, 20+ built-in tools, and hardware-aware local model selection.
  121. - [backlog](https://github.com/backloghq/backlog) - Persistent, cross-session task management. 24 MCP tools for tasks, projects, tags, dependencies, and docs. 7 skills for planning, standups, and handoffs. Event-sourced storage, agent coordination, pure TypeScript. ([Website](https://backloghq.io))
  122. ### Companion & Personality
  123. - [claude-familiar](https://github.com/yaniv-golan/claude-familiar) - Enhance Claude Code's `/buddy` companion with personality, mood, lore, and interactive commands (fortune, roast, haiku, focus timer). Mood shifts automatically on tool success/failure. Extensible — other plugins can layer traits and lore via `"x-familiarExtensions"` in their `plugin.json`.
  124. ### Image and Video Generation
  125. - [nano-banana](https://github.com/Ibrahim-3d/nano-banana-claude-plugin) - Google Gemini image generation plugin. Text-to-image, text-guided image editing, style transfer, 4K output, search grounding, and multi-reference composition — all from a single `/genimage` command. Powered by `gemini-2.5-flash-image` and `gemini-3-pro-image-preview`.
  126. - [taisly-agent-kit](https://github.com/taisly/agent) - Claude Code plugin, skill, SDK, CLI, and MCP server for publishing short-form videos to TikTok, Instagram Reels, YouTube Shorts, X, and Facebook through Taisly.
  127. ## Getting Started
  128. ### Using Plugins
  129. Clone the repo and run Claude with any plugin:
  130. ```bash
  131. git clone https://github.com/composiohq/awesome-claude-plugins.git
  132. cd awesome-claude-plugins
  133. claude --plugin-dir ./commit
  134. ```
  135. Load multiple plugins at once:
  136. ```bash
  137. claude --plugin-dir ./commit --plugin-dir ./code-review --plugin-dir ./connect-apps
  138. ```
  139. ### Plugin Structure
  140. Each plugin follows the standard Claude Code plugin format:
  141. ```
  142. plugin-name/
  143. ├── .claude-plugin/
  144. │ └── plugin.json # Plugin metadata
  145. ├── skills/ # Skill definitions (optional)
  146. │ └── skill-name/
  147. │ └── SKILL.md
  148. ├── commands/ # Slash commands (optional)
  149. │ └── command.md
  150. ├── agents/ # Agent definitions (optional)
  151. │ └── agent.md
  152. └── hooks/ # Event hooks (optional)
  153. └── hooks.json
  154. ```
  155. ## Contributing
  156. Want to add your plugin?
  157. 1. Fork this repository
  158. 2. Add your plugin folder with the standard structure
  159. 3. Update this README with your plugin details
  160. 4. Submit a pull request
  161. Please ensure your plugin:
  162. - Addresses a real use case
  163. - Doesn't duplicate existing functionality
  164. - Follows the template structure
  165. - Has been tested
  166. ## Resources
  167. - [Claude Code Documentation](https://code.claude.com/docs)
  168. - [Plugin Development Guide](https://code.claude.com/docs/en/plugins)
  169. - [Discover Plugins](https://code.claude.com/docs/en/discover-plugins)
  170. - [ComposioHQ/awesome-claude-skills](https://github.com/ComposioHQ/awesome-claude-skills) - More skills and resources
  171. ## License
  172. MIT - See individual plugins for their specific licenses.
audit-project/lib/enhance/prompt-analyzer.js · Bundled script · 429 lines · 1 finding marked
  1. /**
  2. * Prompt Analyzer
  3. * Analyzes general prompts for prompt engineering best practices
  4. *
  5. * @author Avi Fenesh
  6. * @license MIT
  7. */
  8. const fs = require('fs');
  9. const path = require('path');
  10. const { promptPatterns, estimateTokens } = require('./prompt-patterns');
  11. const reporter = require('./reporter');
  12. /**
  13. * Detect prompt file type from path or content
  14. * @param {string} filePath - File path
  15. * @param {string} content - File content
  16. * @returns {string} File type: 'agent', 'command', 'skill', 'prompt', 'markdown'
  17. */
  18. function detectPromptType(filePath, content) {
  19. const lowerPath = filePath.toLowerCase();
  20. // Check path patterns
  21. if (lowerPath.includes('/agents/') || lowerPath.includes('\\agents\\')) {
  22. return 'agent';
  23. }
  24. if (lowerPath.includes('/commands/') || lowerPath.includes('\\commands\\')) {
  25. return 'command';
  26. }
  27. if (lowerPath.includes('/skills/') || lowerPath.includes('\\skills\\')) {
  28. return 'skill';
  29. }
  30. if (lowerPath.includes('/prompts/') || lowerPath.includes('\\prompts\\')) {
  31. return 'prompt';
  32. }
  33. // Check content patterns
  34. if (content) {
  35. // Agent frontmatter
  36. if (/^---\s*\nname:\s*\w+/m.test(content)) {
  37. return 'agent';
  38. }
  39. // System prompt indicators
  40. if (/<system>/i.test(content) || /^##?\s*system\s+prompt/im.test(content)) {
    • Note: Usual in code (tag names in paths and patterns): Contains a <system> block, a common wrapper for instructions hidden in a tool description
    • Line 44 on GitHub
  41. return 'prompt';
  42. }
  43. }
  44. return 'markdown';
  45. }
  46. /**
  47. * Analyze a single prompt file
  48. * @param {string} promptPath - Path to prompt file
  49. * @param {Object} options - Analysis options
  50. * @param {boolean} options.verbose - Include LOW certainty issues
  51. * @returns {Object} Analysis results
  52. */
  53. function analyzePrompt(promptPath, options = {}) {
  54. const { verbose = false } = options;
  55. const results = {
  56. promptName: path.basename(promptPath, path.extname(promptPath)),
  57. promptPath,
  58. promptType: null,
  59. tokenCount: 0,
  60. clarityIssues: [],
  61. structureIssues: [],
  62. exampleIssues: [],
  63. contextIssues: [],
  64. outputIssues: [],
  65. antiPatternIssues: []
  66. };
  67. // Read file
  68. if (!fs.existsSync(promptPath)) {
  69. results.structureIssues.push({
  70. issue: 'File not found',
  71. file: promptPath,
  72. certainty: 'HIGH',
  73. patternId: 'file_not_found'
  74. });
  75. return results;
  76. }
  77. let content;
  78. try {
  79. content = fs.readFileSync(promptPath, 'utf8');
  80. } catch (err) {
  81. results.structureIssues.push({
  82. issue: `Failed to read file: ${err.message}`,
  83. file: promptPath,
  84. certainty: 'HIGH',
  85. patternId: 'read_error'
  86. });
  87. return results;
  88. }
  89. // Detect prompt type
  90. results.promptType = detectPromptType(promptPath, content);
  91. // Calculate token count
  92. results.tokenCount = estimateTokens(content);
  93. // Run each pattern check
  94. for (const pattern of Object.values(promptPatterns)) {
  95. // Skip LOW certainty unless verbose
  96. if (pattern.certainty === 'LOW' && !verbose) {
  97. continue;
  98. }
  99. // Run the check
  100. const result = pattern.check(content);
  101. if (result) {
  102. const issue = {
  103. ...result,
  104. file: promptPath,
  105. certainty: pattern.certainty,
  106. patternId: pattern.id,
  107. autoFix: pattern.autoFix
  108. };
  109. // Route to appropriate issue category
  110. switch (pattern.category) {
  111. case 'clarity':
  112. results.clarityIssues.push(issue);
  113. break;
  114. case 'structure':
  115. results.structureIssues.push(issue);
  116. break;
  117. case 'examples':
  118. results.exampleIssues.push(issue);
  119. break;
  120. case 'context':
  121. results.contextIssues.push(issue);
  122. break;
  123. case 'output':
  124. results.outputIssues.push(issue);
  125. break;
  126. case 'anti-pattern':
  127. results.antiPatternIssues.push(issue);
  128. break;
  129. default:
  130. results.structureIssues.push(issue);
  131. }
  132. }
  133. }
  134. return results;
  135. }
  136. /**
  137. * Analyze all prompts in a directory
  138. * @param {string} promptsDir - Path to prompts directory
  139. * @param {Object} options - Analysis options
  140. * @returns {Array} Array of analysis results
  141. */
  142. function analyzeAllPrompts(promptsDir, options = {}) {
  143. const { recursive = true, extensions = ['.md', '.txt'], ...analyzeOptions } = options;
  144. const results = [];
  145. // Validate and normalize path
  146. if (!promptsDir || typeof promptsDir !== 'string') {
  147. return results;
  148. }
  149. // Resolve to absolute path to prevent path traversal
  150. const resolvedDir = path.resolve(promptsDir);
  151. if (!fs.existsSync(resolvedDir)) {
  152. return results;
  153. }
  154. // Collect prompt files
  155. const promptFiles = [];
  156. function findPromptFiles(dir) {
  157. let entries;
  158. try {
  159. entries = fs.readdirSync(dir, { withFileTypes: true });
  160. } catch (err) {
  161. return;
  162. }
  163. for (const entry of entries) {
  164. const fullPath = path.join(dir, entry.name);
  165. // Ensure traversed paths stay within the resolved directory
  166. const resolvedFullPath = path.resolve(fullPath);
  167. if (!resolvedFullPath.startsWith(resolvedDir)) {
  168. continue;
  169. }
  170. if (entry.isDirectory() && recursive) {
  171. // Skip common non-prompt directories
  172. if (!['node_modules', '.git', 'dist', 'build', 'tests', '__tests__'].includes(entry.name)) {
  173. findPromptFiles(fullPath);
  174. }
  175. } else if (entry.isFile()) {
  176. const ext = path.extname(entry.name).toLowerCase();
  177. if (extensions.includes(ext)) {
  178. // Skip README files
  179. if (entry.name.toLowerCase() !== 'readme.md') {
  180. promptFiles.push(fullPath);
  181. }
  182. }
  183. }
  184. }
  185. }
  186. findPromptFiles(resolvedDir);
  187. // Analyze each file
  188. for (const promptFile of promptFiles) {
  189. const result = analyzePrompt(promptFile, analyzeOptions);
  190. results.push(result);
  191. }
  192. return results;
  193. }
  194. /**
  195. * Main analyze function
  196. * @param {Object} options - Analysis options
  197. * @param {string} options.prompt - Specific prompt file path (optional)
  198. * @param {string} options.promptsDir - Path to prompts directory
  199. * @param {boolean} options.verbose - Include LOW certainty issues
  200. * @returns {Object|Array} Analysis results
  201. */
  202. function analyze(options = {}) {
  203. const {
  204. prompt,
  205. promptsDir,
  206. verbose = false
  207. } = options;
  208. if (prompt) {
  209. // Check if prompt is a directory or file
  210. try {
  211. const stats = fs.statSync(prompt);
  212. if (stats.isDirectory()) {
  213. return analyzeAllPrompts(prompt, { verbose });
  214. } else {
  215. return analyzePrompt(prompt, { verbose });
  216. }
  217. } catch (err) {
  218. // If doesn't exist, let analyzePrompt handle the error
  219. return analyzePrompt(prompt, { verbose });
  220. }
  221. } else if (promptsDir) {
  222. return analyzeAllPrompts(promptsDir, { verbose });
  223. } else {
  224. // Default: analyze common prompt locations
  225. const defaultDirs = ['prompts', 'agents', 'commands', 'skills'];
  226. const allResults = [];
  227. for (const dir of defaultDirs) {
  228. if (fs.existsSync(dir)) {
  229. const results = analyzeAllPrompts(dir, { verbose });
  230. allResults.push(...results);
  231. }
  232. }
  233. return allResults.length > 0 ? allResults : [];
  234. }
  235. }
  236. /**
  237. * Apply fixes to analysis results
  238. * Currently only aggressive_emphasis is auto-fixable
  239. * @param {Object|Array} results - Analysis results
  240. * @param {Object} options - Fix options
  241. * @returns {Object} Fix results
  242. */
  243. function applyFixes(results, options = {}) {
  244. const { dryRun = false, backup = true } = options;
  245. const fixResults = {
  246. applied: [],
  247. skipped: [],
  248. errors: []
  249. };
  250. // Collect all issues
  251. let allIssues = [];
  252. if (Array.isArray(results)) {
  253. for (const r of results) {
  254. allIssues.push(...(r.clarityIssues || []));
  255. allIssues.push(...(r.structureIssues || []));
  256. allIssues.push(...(r.exampleIssues || []));
  257. allIssues.push(...(r.contextIssues || []));
  258. allIssues.push(...(r.outputIssues || []));
  259. allIssues.push(...(r.antiPatternIssues || []));
  260. }
  261. } else {
  262. allIssues.push(...(results.clarityIssues || []));
  263. allIssues.push(...(results.structureIssues || []));
  264. allIssues.push(...(results.exampleIssues || []));
  265. allIssues.push(...(results.contextIssues || []));
  266. allIssues.push(...(results.outputIssues || []));
  267. allIssues.push(...(results.antiPatternIssues || []));
  268. }
  269. // Filter to auto-fixable HIGH certainty issues
  270. const fixableIssues = allIssues.filter(i =>
  271. i.certainty === 'HIGH' && i.autoFix
  272. );
  273. // Group by file
  274. const byFile = new Map();
  275. for (const issue of fixableIssues) {
  276. const fp = issue.file;
  277. if (!byFile.has(fp)) {
  278. byFile.set(fp, []);
  279. }
  280. byFile.get(fp).push(issue);
  281. }
  282. // Process each file
  283. for (const [filePath, fileIssues] of byFile) {
  284. try {
  285. if (!fs.existsSync(filePath)) {
  286. fixResults.errors.push({ filePath, error: 'File not found' });
  287. continue;
  288. }
  289. let content = fs.readFileSync(filePath, 'utf8');
  290. const appliedToFile = [];
  291. for (const issue of fileIssues) {
  292. try {
  293. if (issue.patternId === 'aggressive_emphasis') {
  294. content = fixAggressiveEmphasis(content);
  295. appliedToFile.push({
  296. issue: issue.issue,
  297. fix: 'Reduced aggressive emphasis',
  298. filePath
  299. });
  300. }
  301. // Add more fixers as needed
  302. } catch (err) {
  303. fixResults.errors.push({
  304. issue: issue.issue,
  305. filePath,
  306. error: err.message
  307. });
  308. }
  309. }
  310. // Write changes
  311. if (!dryRun && appliedToFile.length > 0) {
  312. if (backup) {
  313. fs.writeFileSync(`${filePath}.backup`, fs.readFileSync(filePath, 'utf8'), 'utf8');
  314. }
  315. fs.writeFileSync(filePath, content, 'utf8');
  316. }
  317. fixResults.applied.push(...appliedToFile);
  318. } catch (err) {
  319. fixResults.errors.push({
  320. filePath,
  321. error: err.message
  322. });
  323. }
  324. }
  325. return fixResults;
  326. }
  327. /**
  328. * Fix aggressive emphasis in content
  329. * @param {string} content - Content to fix
  330. * @returns {string} Fixed content
  331. */
  332. function fixAggressiveEmphasis(content) {
  333. if (!content) return content;
  334. // Replace aggressive CAPS phrases with normal case
  335. const replacements = [
  336. { pattern: /\bCRITICAL\b/g, replacement: 'critical' },
  337. { pattern: /\bIMPORTANT\b/g, replacement: 'important' },
  338. { pattern: /\bMUST\b/g, replacement: 'must' },
  339. { pattern: /\bNEVER\b/g, replacement: 'never' },
  340. { pattern: /\bALWAYS\b/g, replacement: 'always' },
  341. { pattern: /\bREQUIRED\b/g, replacement: 'required' },
  342. { pattern: /\bMANDATORY\b/g, replacement: 'mandatory' },
  343. { pattern: /\bESSENTIAL\b/g, replacement: 'essential' },
  344. { pattern: /\bWARNING\b/g, replacement: 'warning' },
  345. { pattern: /\bCAUTION\b/g, replacement: 'caution' }
  346. ];
  347. let result = content;
  348. for (const { pattern, replacement } of replacements) {
  349. result = result.replace(pattern, replacement);
  350. }
  351. // Reduce multiple exclamation marks
  352. result = result.replace(/!{2,}/g, '!');
  353. return result;
  354. }
  355. /**
  356. * Generate report from analysis results
  357. * @param {Object|Array} results - Analysis results
  358. * @param {Object} options - Report options
  359. * @returns {string} Markdown report
  360. */
  361. function generateReport(results, options = {}) {
  362. if (Array.isArray(results)) {
  363. return reporter.generatePromptSummaryReport(results, options);
  364. } else {
  365. return reporter.generatePromptReport(results, options);
  366. }
  367. }
  368. module.exports = {
  369. analyzePrompt,
  370. analyzeAllPrompts,
  371. analyze,
  372. applyFixes,
  373. fixAggressiveEmphasis,
  374. generateReport,
  375. detectPromptType,
  376. estimateTokens
  377. };

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.