add-prompt

add-prompt is a command for Claude Code from Matt-Dionis/claude-code-configs. It costs 0 tokens per session (1,631 once invoked), scanned A, original, MIT.

A command that adds reusable prompt templates to an MCP server. A prompt template is a saved conversation pattern with optional typed inputs.

In plain words
What is it for?
Use it to create prompts for tasks such as code review, data analysis, or documentation, with named arguments such as strings, numbers, arrays, and optional values.
Why use it?
It avoids repeatedly creating prompt files, tests, and index entries by hand when adding a new reusable interaction.

Command for Claude Code

Written for Claude Code: installed under .claude/.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is import type { Prompt, PromptMessage } from '../types/prompts.js';.

Good fit Use it to create prompts for tasks such as code review, data analysis, or documentation, with named arguments such as strings, numbers, arrays, and optional values.

Compare 6 commands from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/Matt-Dionis/claude-code-configs
agentmods
npx agentmods add commands/matt-dionis/claude-code-configs/add-prompt

Made for: Claude Code.

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 add-prompt

README.md
[![agentmods](https://agentmods.dev/badge/commands/matt-dionis/claude-code-configs/add-prompt.svg)](https://agentmods.dev/commands/matt-dionis/claude-code-configs/add-prompt)
Your own site
<a href="https://agentmods.dev/commands/matt-dionis/claude-code-configs/add-prompt"><img src="https://agentmods.dev/badge/commands/matt-dionis/claude-code-configs/add-prompt.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,631 The whole file, excluding the scripts and references it only reads on demand.
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.00000 $0.01631
Opus 5 $0.00000 $0.00816
Sonnet 5 $0.00000 $0.00326
Haiku 4.5 $0.00000 $0.00163

Measured 8d ago against content hash d446d1d16d4d, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

add-prompt 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 8d 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.

configurations/mcp-servers/simple-mcp-server/.claude/commands/add-prompt.md · 242 lines

How it starts

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

Add Prompt Template to MCP Server

Adds a new prompt template to your MCP server for reusable conversation patterns.

Usage

/add-prompt <name> <description> [arguments]

Examples

/add-prompt code_review "Review code for improvements" language:string file:string?
/add-prompt analyze_data "Analyze data patterns" dataset:string metrics:array
/add-prompt generate_docs "Generate documentation" codebase:string style:enum[minimal,detailed]

Implementation

import * as fs from 'fs/promises';
import * as path from 'path';

async function addPrompt(
  name: string,
  description: string,
  argumentDefs?: string[]
) {
  // Parse arguments
  const args = parsePromptArguments(argumentDefs || []);
  
  // Generate prompt file
  const promptContent = generatePromptFile(name, description, args);
  
  // Write prompt file
  const promptPath = path.join('src/prompts', `${name}.ts`);
  await fs.writeFile(promptPath, promptContent);
  
  // Update prompt index
  await updatePromptIndex(name);
  
  // Generate test file
  const testContent = generatePromptTest(name);
  const testPath = path.join('tests/unit/prompts', `${name}.test.ts`);
  await fs.writeFile(testPath, testContent);
  
  console.log(`✅ Prompt "${name}" added successfully!`);
  console.log(`  - Implementation: ${promptPath}`);
  console.log(`  - Test file: ${testPath}`);
  console.log(`\nNext steps:`);
  console.log(`  1. Define the prompt template in ${promptPath}`);
  console.log(`  2. Test with MCP Inspector`);
}

interface PromptArgument {
  name: string;
  description: string;
  required: boolean;
  type: string;
}

function parsePromptArguments(argumentDefs: string[]): PromptArgument[] {
  return argumentDefs.map(def => {
    const [nameWithType, description] = def.split('=');
    const [nameType] = nameWithType.split(':');
    const isOptional = nameType.endsWith('?');
    const name = isOptional ? nameType.slice(0, -1) : nameType;
    const type = nameWithType.split(':')[1] || 'string';
    
    return {
      name,
      description: description || `${name} parameter`,
      required: !isOptional,
      type: type.replace('?', ''),
    };
  });
}

function generatePromptFile(
  name: string,
  description: string,
  args: PromptArgument[]
): string {
  return `
import type { Prompt, PromptMessage } from '../types/prompts.js';

export const ${name}Prompt: Prompt = {
  name: '${name}',
  description: '${description}',
  arguments: [
${args.map(arg => `    {
      name: '${arg.name}',
      description: '${arg.description}',
      required: ${arg.required},
    },`).join('\n')}
  ],
};

export function get${capitalize(name)}Prompt(
  args: Record<string, unknown>
): PromptMessage[] {
  // Validate required arguments
${args.filter(a => a.required).map(arg => `  if (!args.${arg.name}) {
    throw new Error('Missing required argument: ${arg.name}');
  }`).join('\n')}
  
  // Build prompt messages
  const messages: PromptMessage[] = [];
  
  // System message (optional)
  messages.push({
    role: 'system',
    content: {
      type: 'text',
      text: buildSystemPrompt(args),
    },
  });
  
  // User message
  messages.push({
    role: 'user',
    content: {
      type: 'text',
      text: buildUserPrompt(args),
    },
  });
  
  return messages;
}

function buildSystemPrompt(args: Record<string, unknown>): string {
  // TODO: Define the system prompt template
  return \`You are an expert assistant helping with ${description.toLowerCase()}.\`;
}

function buildUserPrompt(args: Record<string, unknown>): string {
  // TODO: Define the user prompt template
  let prompt = '${description}\\n\\n';
  
${args.map(arg => `  if (args.${arg.name}) {
    prompt += \`${capitalize(arg.name)}: \${args.${arg.name}}\\n\`;
  }`).join('\n')}
  
  return prompt;
}

function capitalize(str: string): string {
  return str.charAt(0).toUpperCase() + str.slice(1);
}
`;
}

function generatePromptTest(name: string): string {
  return `
import { describe, it, expect } from 'vitest';

Read the full file on GitHub · 242 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. 8d ago First seen · 242 lines · 0 tokens per session scan A d446d1d16d4d

Subscribe to this mod's changes

add-prompt is a command published in the GitHub repository Matt-Dionis/claude-code-configs (624 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,631 tokens. 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-30.