Claude Prompts

repository·main·Indexed 41 days ago

https://github.com/minipuft/claude-prompts

A portable workflow layer for AI coding harnesses providing reusable prompt resources, composable chains, validation gates, and client-native skill export. Includes a CPM CLI for workspace management, an MCP server for prompt engine and resource management, and behavior guardrail hooks for Claude Code.

Tokens
204.2K
Snippets
509
Records
940
Agent score
52%

What's inside Claude Prompts

  1. Retirement of Semantic LLM Side-Client and SemanticGateService

    main

    As of the August 2026 updates, the Semantic LLM Side-Client and the SemanticGateService have been retired. This change removes the ability to use an LLM-based side-client for semantic analysis and gate services, moving the system toward a unified, unconditional compositional gate service model.

    Key Changes for Consumers:

    • Semantic Analysis: The SemanticIntegrationFactory has been removed. Consumers (such as MCP tools) should now call createContentAnalyzer(logger, config) directly.
    • Gate Services: GateServiceConfig no longer accepts llmIntegration options. The GateService is now unconditional and always returns a compositional service.
    • Type Narrowing: The GateService.serviceType and GateValidationResult.validatedBy fields have been narrowed from 'compositional' | 'semantic' to just 'compositional'.
    • CLI Changes: The CLI help text has been updated to remove retired *.mode spellings, repointing to canonical keys. The analysis mode remains but is marked as deprecated.
  2. Understand the Semantic Module Governance model

    main

    The project uses a governance model to ensure that AI agent instructions, architecture documentation, and actual code dependencies remain synchronized.

    Core Principles:

    • Authored Guidance: CLAUDE.md and scoped project rules (found in .claude/rules/*.md) are the only sources of truth for project guidance.
    • Generated Projections: AGENTS.md is a generated, byte-checkable semantic projection of the authored guidance. It is intended to be consumed by agents but should not be edited manually.
    • Semantic Boundaries: Modules are defined by semantic boundaries. Any direct child of a boundary declaring children: semantic must have a corresponding module.yaml file.
    • Observed Facts: dependency-cruiser provides the observed import facts used to validate architecture and populate the module catalog.
    • Deterministic Documentation: The docs/reference/module-catalog.md file is a generated, deterministic file used to track the module landscape and is checked for drift against the actual code structure.
  3. Avoid path resolution defects in read/write pairs

    main

    When implementing or extending a capability that involves both reading and writing (such as configuration or resource management), follow this pattern to avoid parity defects:

    Pattern: Shared Resolver Verification Before designing a new write path to support a feature that already works for reads (like overlays or workspace-relative paths), verify that both sides of the read/write pair share the same resolver.

    If the read path uses a complex resolution chain (e.g., checking overlays, environment variables, and local directories) but the write path only resolves against a static config file, the write path will fail to target the correct destination even if the logic is 'correct' for a standard file system.

  4. Understand the prompt instruction surface and security implications

    main

    When using the claude-prompts MCP server, be aware that prompt content is treated as direct instruction to the AI model. Specifically, the following fields can reach the client and influence the model's behavior:

    • systemMessage: Sent on invocation, or via list detail:"full" if not present.
    • userMessageTemplate: Sent on invocation.
    • description: Sent at connection via the MCP prompts/list method.
    • Argument descriptions: Sent at connection via the MCP prompts/list method.

    Security Warning: Because the MCP prompts/list method is typically called by clients automatically upon connection, a malicious or 'poisoned' description in a prompt pack can land in the model's context without explicit user action. This is considered an 'instruction-surface poisoning' risk, which is an accepted characteristic of the product. However, the server prevents this from escalating to arbitrary code execution (e.g., sh -c) through established security tiers.

  5. Use Routing Hints for model selection and cost estimation

    main

    When MASTRA_ROUTING_HINTS_ENABLED is active, the prompt_engine tool returns the rendered prompt along with metadata containing routing decisions. This allows the host LLM to make informed decisions about which model to use based on cost and latency.

    Metadata Structure

    The prompt_engine response includes a routingHints object within the metadata:

    • selectedModel: The suggested model.
    • reasoning: Why this model was selected.
    • estimatedCost: The predicted cost for the operation.
    • estimatedLatency: The predicted latency.

    Note: The server does not automatically call the suggested model; it only provides the hint to the host LLM.

  6. Understand Claude Code plugin data persistence and directory structure

    main

    When using claude-prompts as a plugin in Claude Code, data persistence is handled via specific environment variables and directory structures. This ensures that plugin state (like settings or history) survives updates and is separated from the source code.

    Key Environment Variables

    • CLAUDE_PLUGIN_ROOT: The root directory of the plugin.
    • CLAUDE_PLUGIN_DATA: The dedicated directory for persistent plugin data. This is substituted in .mcp.json env and args.
    • MCP_WORKSPACE: In claude-prompts, this is set to ${CLAUDE_PLUGIN_ROOT}. Note that the plugin's own environment may override this.

    Data Directory Naming

    The location of your persistent data depends on how the plugin was loaded:

    • Manual/Development Load: If loaded via --plugin-dir, the data directory is named ~/.claude/plugins/data/<plugin-name>-inline/.
    • Marketplace Install: If installed via a marketplace, the directory follows the pattern ~/.claude/plugins/data/<plugin-name>-<marketplace>/.

    Persistence Behavior

    • What is persistent: When a plugin is updated, the data directory remains. However, if you are developing locally and the plugin is loaded from a source checkout, the data directory is treated as a separate entity from the source files.
    • What is transient: Files located in {CLAUDE_PLUGIN_ROOT}/server/runtime-state (such as hooks-state.db) are considered transient session rows and are not moved to the durable data directory unless explicitly handled.
  7. Understand the benefits of using Hooks

    main

    Hooks enable the use of operators (>>, -->, ==>, ::) directly in conversation, making workflows feel native rather than mediated.

    Key capabilities unlocked by Hooks:

    • Auto-routing: >>research_chain topic:'X' triggers the correct MCP tool call automatically.
    • Chain continuity across compaction: Multi-step chains preserve state even when the LLM context is compacted mid-execution.
    • Cross-step verdict tracking: Gate pass/fail results are shared across all steps without the LLM needing to re-derive them.
    • Native agent handoffs: ==> automatically routes to the client's subagent system.
    • Session persistence: Workflow state is preserved during context compaction.

    Client Support:

    • Full Support: Claude Code, OpenCode.
    • Partial Support: Gemini CLI.
    • Experimental Support: Codex (requires a one-time /hooks trust review; off by default).
  8. Understand the Agent Plugins Migration and Surface Alignment

    main

    The project is migrating to a 'Single Source Tree, Rendered Distributions' model for Agent Plugins. This migration affects how different surfaces interact with the core claude-prompts engine.

    Key surfaces and their end states:

    • npm package (claude-prompts): Remains the single engine. It is declared in mcp.json.
    • Hooks: The root hooks/ directory is the single source of truth and is consumed via npm. Other clients like Gemini and Codex ship thin ADAPTERS over these hooks because their event models differ. Note that Agent Plugins 1.0.0 does not define core hooks or a client namespace string.
    • Marketplaces: The minipuft-plugins repository serves as a 2-file index that lists claude-prompts (referencing this repo's dist) and codex-prompts. URLs in these listings are permanent and do not change.
    • GitHub workflows: The release process moves from version-sync PRs to a render-based flow: npm → extensions → dist → render the Claude Code projections → drift check.
  9. Codex Platform Hook Requirements and Constraints

    main

    To use hooks with the Codex CLI, ensure the following platform requirements are met:

    • Feature Flag: Hooks are experimental and must be enabled in config.toml using [features] hooks = true.
    • OS Support: Hooks are not supported on Windows.
    • Minimum Version: Requires Codex hooks version >=0.117.
    • Timeout Units: Timeouts are measured in seconds (consistent with Claude Code, unlike Gemini's milliseconds).
    • Hosted Tools: Tools like WebSearch do not trigger Pre/PostToolUse events.
    • Context Limits: The additionalContextLimit defaults to approximately 2500 tokens. If the context overflows, it spills to disk and only a preview is shown to the model, which can break imperative directives.
    • Trust Model: Plugin hooks require explicit user approval via the /hooks command. Trust is recorded against the hook's hash and must be re-verified if the hook changes.
  10. Understand MCP_RESOURCES_PATH and MCP_WORKSPACE requirements

    main

    When configuring or extending claude-prompts (or its sibling repositories like gemini-prompts and opencode-prompts), be aware of how environment variables are used for path resolution. Misconfigurations in these variables can lead to startup refusals or silent failures:

    • MCP_RESOURCES_PATH: Used to locate resources. In some setups (like gemini-prompts), this is set to ${extensionPath}/node_modules/claude-prompts/resources. Note that if a client clones a repository without installing dependencies, node_modules/ will be missing, making this path invalid.
    • MCP_WORKSPACE: Used for workspace-relative path resolution. Some installers (like opencode-prompts) use relative paths like ./node_modules/claude-prompts resolved from the server's working directory. If this variable is invalid or missing, certain CLI commands or hooks may fail or skip operations silently.

    Warning for skills-sync users: The skills-sync CLI contains a silent fallback for MCP_RESOURCES_PATH (server/src/modules/skills-sync/service.ts:50-51). If you have a typo in this variable, the CLI may default to exporting a bundled set into client skill directories instead of failing, which can lead to unexpected behavior.

  11. How Prompt Analysis icons are determined

    main

    The getAnalysisIcon function (found in prompt-analyzer.ts) determines which icon to display for prompt analysis. Following the retirement of semantic analysis, the icon logic has been simplified to a ternary structure with two primary outcomes:

    • 🚨: Returned when the analysis process throws an error.
    • 🧠: The default icon returned for successful analysis (replacing previous arms like 'semantic', 'structural', 'hybrid', 'configurable', and 'disabled').

    Note: While 'structural' and 'hybrid' arms may still exist in the code without producers, they are considered dead arms and do not affect the rendered output.

  12. Organize Content between README and docs/

    main

    To maintain a clean user experience, distinguish between high-level entry points (README) and deep technical details (docs/).

    Content TypeREADMEdocs/
    What it does1-2 sentencesNo
    InstallationInstall + first useDetailed per-client guides
    FeaturesOverview with examplesFull tutorials
    ArchitectureBrief diagram (optional)Full treatment
    ConfigurationLink onlyFull reference
    TroubleshootingNoYes
    ConceptsOne sentence + linkFull treatment