Token导航 LogoToken导航

Agent Skill · 研究检索

prompt-engine(提示引擎)

用于辅助提示词、系统指令、Agent 行为约束和工作流模板的整理。它适合让 Agent 规范任务边界、统一输出格式、拆分操作步骤或优化提示词可复用性。使用时需要保留真实业务约束,不要把示例当硬规则;涉及自动执行、外部工具或高风险操作时,应在提示词中明确确认步骤、权限边界和失败处理方式。

prompt-engine 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为只读;许可证信息还不明确,第三方扫描有未通过项,按安装量在研究检索类的 73,675 个 Skill 里排第 53,488。

总安装 533周安装 22GitHub Stars 777下载 174核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:prompt-engine(提示引擎)
来源仓库:https://github.com/dadbodgeoff/drift
仓库路径:skills/prompt-engine
安装命令:
npx skills add https://github.com/dadbodgeoff/drift --skill prompt-engine
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/dadbodgeoff/drift --skill prompt-engine

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

用于辅助提示词、系统指令、Agent 行为约束和工作流模板的整理。适合让 Agent 规范任务边界、统一输出格式或优化提示词可复用性。通过安装命令添加,使用时需保留真实业务约束,避免将示例当硬规则。涉及自动执行或外部工具调用时,应在提示词中明确确认步骤和权限边界。

prompt-engine 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/prompt-engine

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/dadbodgeoff/drift --skill prompt-engine;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它标注为只读,先用只读任务试一次,确认行为符合预期再扩大使用范围。

常见问题

6 条

prompt-engine 怎么安装?

在终端执行 npx skills add https://github.com/dadbodgeoff/drift --skill prompt-engine。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

prompt-engine 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

prompt-engine 需要什么权限?

权限级别是只读。该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

prompt-engine 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

prompt-engine 用的人多吗?

公开数据是累计安装 533 次,近一周安装 22 次,下载 174 次,GitHub 777 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

prompt-engine 安全吗?

第三方扫描有未通过项,风险较高。除非你确认过源码,否则不建议直接安装到常用环境。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 标注为只读权限,试用阶段不容易误改本地文件。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。
  • 只想先试试效果、不希望它改动本地文件的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
prompt-engine

提示引擎 · 本页

533777只读未明确未通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

AI Prompt Templating Engine

Template-based prompt building with brand consistency and security.

When to Use This Skill

  • Managing AI prompts across a codebase
  • Need brand consistency in generated content
  • Preventing prompt injection attacks
  • Optimizing token usage with compact context

Core Concepts

Prompt engineering challenges:

  1. Scattered prompts - Hard to maintain consistency
  2. Brand drift - Generated content doesn't match brand
  3. Injection attacks - User input can hijack prompts
  4. Token waste - Verbose context burns budget

Implementation

TypeScript

// Types
interface PromptTemplate {
  name: string;
  version: string;
  basePrompt: string;
  placeholders: string[];
  qualityModifiers: string[];
}

interface BrandKitContext {
  primaryColors: string[];
  accentColors: string[];
  headlineFont?: string;
  bodyFont?: string;
  tone?: string;
}

interface ResolvedBrandContext {
  primaryColor?: string;
  secondaryColor?: string;
  accentColor?: string;
  gradient?: string;
  font?: string;
  tone?: string;
  intensity: 'subtle' | 'balanced' | 'strong';
}

// Security: Input Sanitization
const MAX_INPUT_LENGTH = 500;
const SANITIZE_PATTERN = /[<>{}\[\]\\|`~]/g;

const INJECTION_PATTERNS = [
  /ignore\s+(previous|above|all)/i,
  /disregard\s+(previous|above|all)/i,
  /system\s*:/i,
  /assistant\s*:/i,
  /\[INST\]/i,
  /<<SYS>>/i,
];

function sanitizeInput(input: string): string {
  if (input.length > MAX_INPUT_LENGTH) {
    input = input.slice(0, MAX_INPUT_LENGTH);
  }

  input = input.replace(SANITIZE_PATTERN, '');

  for (const pattern of INJECTION_PATTERNS) {
    if (pattern.test(input)) {
      throw new Error('Potential prompt injection detected');
    }
  }

  return input.trim();
}

function sanitizePlaceholders(placeholders: Record<string, string>): Record<string, string> {
  const sanitized: Record<string, string> = {};
  for (const [key, value] of Object.entries(placeholders)) {
    sanitized[key] = sanitizeInput(value);
  }
  return sanitized;
}

// Brand Context Resolver
class BrandContextResolver {
  resolve(
    brandKit: BrandKitContext,
    options: {
      primaryColorIndex?: number;
      secondaryColorIndex?: number;
      accentColorIndex?: number;
      useGradient?: boolean;
      intensity?: 'subtle' | 'balanced' | 'strong';
    } = {}
  ): ResolvedBrandContext {
    const primaryColor = this.resolveColor(brandKit.primaryColors, options.primaryColorIndex ?? 0);
    const secondaryColor = this.resolveColor(brandKit.primaryColors, options.secondaryColorIndex ?? 1);
    const accentColor = this.resolveColor(brandKit.accentColors, options.accentColorIndex ?? 0);

    const gradient = options.useGradient && primaryColor && secondaryColor
      ? `${primaryColor}→${secondaryColor}`
      : undefined;

    return {
      primaryColor,
      secondaryColor,
      accentColor,
      gradient,
      font: brandKit.headlineFont,
      tone: brandKit.tone,
      intensity: options.intensity || 'balanced',
    };
  }

  private resolveColor(colors: string[], index: number): string | undefined {
    if (!colors.length) return undefined;
    return colors[Math.min(index, colors.length - 1)];
  }
}

// Compact brand block (~50-80 tokens)
function toCompactBrandBlock(ctx: ResolvedBrandContext): string {
  const parts: string[] = [];

  const colors = [ctx.primaryColor, ctx.secondaryColor, ctx.accentColor].filter(Boolean);
  if (colors.length) parts.push(`Colors: ${colors.join(', ')}`);
  if (ctx.gradient) parts.push(`Gradient: ${ctx.gradient}`);
  if (ctx.font) parts.push(`Font: ${ctx.font}`);
  if (ctx.tone) parts.push(`Tone: ${ctx.tone}`);

  if (!parts.length) return '';
  return `[BRAND: ${ctx.intensity} - ${parts.join(' | ')}]`;
}

// Template Loader with caching
const templateCache = new Map<string, PromptTemplate>();

async function loadTemplate(templateName: string): Promise<PromptTemplate> {
  if (templateCache.has(templateName)) {
    return templateCache.get(templateName)!;
  }

  // Prevent directory traversal
  const normalized = templateName.replace(/\.\./g, '').replace(/[<>:"|?*]/g, '');

  const content = await fs.readFile(`prompts/${normalized}.yaml`, 'utf-8');
  const data = yaml.load(content) as any;

  const template: PromptTemplate = {
    name: data.name || templateName,
    version: data.version || '1.0.0',
    basePrompt: data.base_prompt,
    placeholders: data.placeholders || [],
    qualityModifiers: data.quality_modifiers || [],
  };

  // Validate placeholders exist in prompt
  for (const placeholder of template.placeholders) {
    if (!template.basePrompt.includes(`{${placeholder}}`)) {
      throw new Error(`Placeholder {${placeholder}} not found in template`);
    }
  }

  templateCache.set(templateName, template);
  return template;
}

// Prompt Engine
const INTENSITY_MODIFIERS = {
  subtle: 'subtly incorporate',
  balanced: 'use',
  strong: 'prominently feature',
};

class PromptEngine {
  private brandResolver = new BrandContextResolver();

  async buildPrompt(
    templateName: string,
    placeholders: Record<string, string>,
    brandKit?: BrandKitContext,
    brandOptions?: Parameters<BrandContextResolver['resolve']>[1]
  ): Promise<string> {
    const sanitizedPlaceholders = sanitizePlaceholders(placeholders);
    const template = await loadTemplate(templateName);

    // Substitute placeholders
    let prompt = template.basePrompt;
    for (const [key, value] of Object.entries(sanitizedPlaceholders)) {
      prompt = prompt.replace(new RegExp(`\\{${key}\\}`, 'g'), value);
    }

    // Inject brand context
    if (brandKit) {
      const resolved = this.brandResolver.resolve(brandKit, brandOptions);
      const brandBlock = toCompactBrandBlock(resolved);

      if (brandBlock) {
        const modifier = INTENSITY_MODIFIERS[resolved.intensity];
        prompt = `${prompt}\n\n${modifier} the following brand guidelines:\n${brandBlock}`;
      }
    }

    // Add quality modifiers
    if (template.qualityModifiers.length) {
      prompt = `${prompt}\n\nQuality: ${template.qualityModifiers.join(', ')}`;
    }

    return prompt;
  }
}

export const promptEngine = new PromptEngine();

Python

import re
import yaml
from dataclasses import dataclass
from typing import Dict, List, Optional
from pathlib import Path

MAX_INPUT_LENGTH = 500
SANITIZE_PATTERN = re.compile(r'[<>{}\[\]\\|`~]')
INJECTION_PATTERNS = [
    re.compile(r'ignore\s+(previous|above|all)', re.I),
    re.compile(r'disregard\s+(previous|above|all)', re.I),
    re.compile(r'system\s*:', re.I),
    re.compile(r'assistant\s*:', re.I),
    re.compile(r'\[INST\]', re.I),
]

def sanitize_input(input_str: str) -> str:
    if len(input_str) > MAX_INPUT_LENGTH:
        input_str = input_str[:MAX_INPUT_LENGTH]

    input_str = SANITIZE_PATTERN.sub('', input_str)

    for pattern in INJECTION_PATTERNS:
        if pattern.search(input_str):
            raise ValueError("Potential prompt injection detected")

    return input_str.strip()

@dataclass
class PromptTemplate:
    name: str
    version: str
    base_prompt: str
    placeholders: List[str]
    quality_modifiers: List[str]

@dataclass
class BrandKitContext:
    primary_colors: List[str]
    accent_colors: List[str]
    headline_font: Optional[str] = None
    tone: Optional[str] = None

@dataclass
class ResolvedBrandContext:
    primary_color: Optional[str] = None
    secondary_color: Optional[str] = None
    accent_color: Optional[str] = None
    gradient: Optional[str] = None
    font: Optional[str] = None
    tone: Optional[str] = None
    intensity: str = "balanced"

class BrandContextResolver:
    def resolve(
        self,
        brand_kit: BrandKitContext,
        primary_index: int = 0,
        secondary_index: int = 1,
        accent_index: int = 0,
        use_gradient: bool = False,
        intensity: str = "balanced",
    ) -> ResolvedBrandContext:
        primary = self._resolve_color(brand_kit.primary_colors, primary_index)
        secondary = self._resolve_color(brand_kit.primary_colors, secondary_index)
        accent = self._resolve_color(brand_kit.accent_colors, accent_index)

        gradient = f"{primary}→{secondary}" if use_gradient and primary and secondary else None

        return ResolvedBrandContext(
            primary_color=primary,
            secondary_color=secondary,
            accent_color=accent,
            gradient=gradient,
            font=brand_kit.headline_font,
            tone=brand_kit.tone,
            intensity=intensity,
        )

    def _resolve_color(self, colors: List[str], index: int) -> Optional[str]:
        if not colors:
            return None
        return colors[min(index, len(colors) - 1)]

def to_compact_brand_block(ctx: ResolvedBrandContext) -> str:
    parts = []

    colors = [c for c in [ctx.primary_color, ctx.secondary_color, ctx.accent_color] if c]
    if colors:
        parts.append(f"Colors: {', '.join(colors)}")
    if ctx.gradient:
        parts.append(f"Gradient: {ctx.gradient}")
    if ctx.font:
        parts.append(f"Font: {ctx.font}")
    if ctx.tone:
        parts.append(f"Tone: {ctx.tone}")

    if not parts:
        return ""
    return f"[BRAND: {ctx.intensity} - {' | '.join(parts)}]"

_template_cache: Dict[str, PromptTemplate] = {}

def load_template(template_name: str) -> PromptTemplate:
    if template_name in _template_cache:
        return _template_cache[template_name]

    # Prevent directory traversal
    safe_name = template_name.replace("..", "").replace("/", "_")
    path = Path("prompts") / f"{safe_name}.yaml"

    with open(path) as f:
        data = yaml.safe_load(f)

    template = PromptTemplate(
        name=data.get("name", template_name),
        version=data.get("version", "1.0.0"),
        base_prompt=data["base_prompt"],
        placeholders=data.get("placeholders", []),
        quality_modifiers=data.get("quality_modifiers", []),
    )

    _template_cache[template_name] = template
    return template

INTENSITY_MODIFIERS = {
    "subtle": "subtly incorporate",
    "balanced": "use",
    "strong": "prominently feature",
}

class PromptEngine:
    def __init__(self):
        self._brand_resolver = BrandContextResolver()

    def build_prompt(
        self,
        template_name: str,
        placeholders: Dict[str, str],
        brand_kit: Optional[BrandKitContext] = None,
        intensity: str = "balanced",
        use_gradient: bool = False,
    ) -> str:
        # Sanitize inputs
        sanitized = {k: sanitize_input(v) for k, v in placeholders.items()}

        template = load_template(template_name)

        # Substitute placeholders
        prompt = template.base_prompt
        for key, value in sanitized.items():
            prompt = prompt.replace(f"{{{key}}}", value)

        # Inject brand context
        if brand_kit:
            resolved = self._brand_resolver.resolve(
                brand_kit, intensity=intensity, use_gradient=use_gradient
            )
            brand_block = to_compact_brand_block(resolved)

            if brand_block:
                modifier = INTENSITY_MODIFIERS[resolved.intensity]
                prompt = f"{prompt}\n\n{modifier} the following brand guidelines:\n{brand_block}"

        # Add quality modifiers
        if template.quality_modifiers:
            prompt = f"{prompt}\n\nQuality: {', '.join(template.quality_modifiers)}"

        return prompt

prompt_engine = PromptEngine()

Template Example

# prompts/thumbnail_gaming.yaml
name: thumbnail_gaming
version: "1.0.0"
base_prompt: |
  Create a {game_name} thumbnail.
  Feature {subject} with {emotion} expression.
  Style: {style}

placeholders:
  - game_name
  - subject
  - emotion
  - style

quality_modifiers:
  - ultra detailed
  - cinematic lighting
  - 8K quality

Usage Examples

const prompt = await promptEngine.buildPrompt(
  'thumbnail_gaming',
  {
    game_name: 'Cyberpunk 2077',
    subject: 'character with katana',
    emotion: 'intense',
    style: 'neon cyberpunk',
  },
  {
    primaryColors: ['#FF00FF', '#00FFFF'],
    accentColors: ['#FFFF00'],
    headlineFont: 'Orbitron',
    tone: 'edgy',
  },
  { useGradient: true, intensity: 'strong' }
);

// Result:
// Create a Cyberpunk 2077 thumbnail.
// Feature character with katana with intense expression.
// Style: neon cyberpunk
//
// prominently feature the following brand guidelines:
// [BRAND: strong - Colors: #FF00FF, #00FFFF, #FFFF00 | Gradient: #FF00FF→#00FFFF | Font: Orbitron | Tone: edgy]
//
// Quality: ultra detailed, cinematic lighting, 8K quality

Best Practices

  1. Sanitize all user inputs before substitution
  2. Use compact brand blocks to save tokens
  3. Cache templates for performance
  4. Validate placeholders exist in templates
  5. Use intensity modifiers for brand prominence

Common Mistakes

  • No input sanitization (injection vulnerability)
  • Verbose brand context (wastes tokens)
  • Hardcoded prompts (inconsistent)
  • Missing placeholder validation
  • No template caching (slow)

Related Patterns

  • ai-generation-client - Use prompts with AI APIs
  • rate-limiting - Protect AI quota
  • validation-quarantine - Validate AI outputs

平台分布

Codex

37.2%
按下载量换算65

Claude

31.64%
按下载量换算55

Cursor

17.67%
按下载量换算31

Gemini CLI

9.72%
按下载量换算17

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

未通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills