SuperAPI AI Directory

prompt-generator

Coding & development

View repository

Updated 11-16 13:47

About this skill

Project Prompt Generator

Compress the project workflow that has already been completed, verified, or corrected in the current session into aproject-level, repeatable, maintainablePi Prompt Template.

This Skill itself is global; the Prompts it generates always belong to the current project.

Core artifacts

By default, only create or update:

<project-root>/.pi/prompts/prompt:<slug>.md

For example:

.pi/prompts/prompt:publish-dyn.md
.pi/prompts/prompt:start-services.md
.pi/prompts/prompt:deploy-devices.md

They correspond to:

/prompt:publish-dyn
/prompt:start-services
/prompt:deploy-devices

<slug> Use short, semantically clear kebab-case; keep the prompt: prefix.

When to generate

Prioritize the following cases:

  • The user explicitly asks to "capture," "reuse," or "turn into a prompt/slash command" the process that just succeeded.
  • A multi-step project operation has already been completed in the session, such as publishing a package, starting a service, deploying, migrating, integration testing, troubleshooting, or rolling back.
  • The user gives a new workflow requirement and wants to repeat it later through a project command.

If the user does not specify a workflow name, prioritize distilling fromthe most recent task trajectory that has been completed or is essentially complete, and do not ask the user to re-describe information that already appears in the session.

Step 1: Locate the project and existing Prompts

First determine the project root directory. For Git repositories, prioritize using:

git rev-parse --show-toplevel

Otherwise, use the current working directory as the project root.

Then check:

<project-root>/.pi/prompts/

Before creating a new file, first read the file with the same name (if it exists) and 1-3 related Prompts to avoid breaking existing conventions.

If .pi/prompts/ does not exist, it may be created.

Step 2: Extract "reusable facts" from the session trajectory

Use two types of input at the same time:

  1. User requirements: final goal, explicit constraints, naming, environment, scope, output requirements.
  2. Session trajectory: files actually read, successful commands, failed attempts, corrections, verification results, final state.

When extracting, layer the facts:

  • Verified facts: actually executed successfully this time and produced the expected result; may be written into the main workflow.
  • Stable project facts: from repository configuration, scripts, README, package.json, Makefile, service definitions, etc.; may be solidified as project knowledge.
  • Transient facts: version numbers, build IDs, deployment IDs, PIDs, temporary ports, tokens, timestamps, current device lists, etc.; do not solidify directly; change them into parameters or runtime discovery.
  • Failure paths: keep only when they can form explicit error-prevention rules, such as "do not run X; use Y instead." Do not move debugging noise into the Prompt.

Do not treat the model's own guesses as facts. If the trajectory conflicts with the current repository state, defer to the current project files and verifiable commands.

Step 3: Decide granularity

One Prompt expresses only one nameable workflow.

Suitable for splitting:

发布 Dyncode 包       -> prompt:publish-dyn.md
启动本地服务         -> prompt:start-services.md
发布并部署到开发设备 -> 如果二者高度绑定,可单独做 prompt:publish-and-deploy-dev.md

Do not cram multiple loosely coupled tasks into one giant Prompt just for the sake of "completeness".

If the user explicitly requests a combined workflow, it may be combined, but the body must have stage boundaries and failure stop conditions.

Step 4: Design parameters

Pi Prompt Template supports:

$1
$2
$@
$ARGUMENTS
${1:-default}
${@:-default}
${@:N}
${@:N:L}

Prefer to expose onlythe inputs that actually change and that the user needs to control.

Example:

argument-hint: "[environment] [target]"

In the body:

环境:${1:-dev}
目标:${2:-all-assigned}

The following content usually should not be hardcoded as fixed values:

  • Release version number
  • artifact/hash/build/deployment ID
  • PID
  • Temporary port
  • One-time URL
  • Current time
  • The device set queried in this run

Prefer to have the Prompt require the agent to compute/read these in real time based on project configuration or the output of the previous command.

Step 5: Write the Prompt

The generated file uses the skeleton below, but tailor it to the workflow; do not mechanically fill in every section:

---
description: <一句话说明这个命令完成什么>
argument-hint: "[可选参数]"
---

完成 <工作流目标>。

用户参数:$ARGUMENTS

## 目标与范围

- <最终状态>
- <作用范围>
- <明确不做什么>

## 执行前检查

1. 确认当前位于正确项目根目录。
2. 读取 <项目内权威配置/脚本>,不要凭记忆猜命令或版本。
3. 检查 <必要服务、凭据、分支、工作区状态等>。

## 执行流程

1. <步骤,引用稳定的项目脚本/命令来源>
2. <从前一步输出提取动态值>
3. <执行下一步>
4. <必要时等待或轮询真实完成状态>

## 验证

- <机器可验证的成功条件 1>
- <成功条件 2>
- 不要仅以“命令退出码为 0”代替业务最终状态(如果还存在异步收敛)。

## 安全与停止条件

- 遇到 <危险/歧义/环境错误> 时停止,不要猜测或扩大范围。
- 不自动修改与本工作流无关的文件。
- 不输出或持久化密钥、token、密码等敏感信息。

## 最终报告

简洁报告:执行范围、关键动态值、成功/失败数量、最终验证结果,以及仍未完成的真实阻塞项。

Prompt writing principles

What is generated is an operating specification for the Agent to execute, not a tutorial for humans to read.

Therefore:

  • Use imperative language.
  • Prefer referencing authoritative scripts and configurations in the project; do not copy large blocks of implementation details that are prone to drift.
  • Write clearly "how to discover dynamic values" instead of hardcoding the values from this session.
  • Write clear final verification conditions, especially for workflows like release, deployment, and service startup where "the command succeeded but the system is not yet ready" easily occurs.
  • Write explicit boundaries and stop conditions for destructive operations.
  • Do not record invalid attempts from this session, unless they can be turned into stable error-prevention rules.
  • Do not hardcode one-time absolute paths; for files within the project, prefer paths relative to the project root.
  • If a command depends on a project-specific CLI/script, first read its help, source code, or existing usage sites to confirm the syntax.

Additional rules for release/deployment workflows

For processes like "publish a dyn package", "build and push", and "deploy to device", at least distinguish:

  1. Build/artifact generation: how the version is determined, and where the artifact is located.
  2. Registration/publishing: how to obtain the immutable artifact coordinates, hash, or version.
  3. Sync/promote: if the server also has stages such as sync/promote, the order must be explicit.
  4. Deployment scope: the target must come from user parameters or a runtime query; do not reuse the target list from last time.
  5. Final convergence verification: distinguish desired state from actual state; for asynchronous systems, wait or poll until real success, or explicitly report that convergence has not yet occurred.

If the current project already has a working script, the Prompt should preferentially call the script and perform pre-checks and post-verification around it, rather than rewriting the same set of low-level API calls by hand.

Additional rules for service startup workflows

For processes like "start the backend/frontend/dependency services", at least confirm:

  1. The startup entry point specified by the project (package script, Makefile, compose, project scripts, etc.).
  2. Required dependency services and startup order.
  3. Dynamic configuration such as ports, profiles, and env files.
  4. How to handle already-running instances, to avoid starting duplicates.
  5. readiness/health verification, not just "the process exists."
  6. Log locations and the shortest diagnostic path when failure occurs.

Unless the user explicitly requests background operation, do not introduce new daemon mechanisms on your own; prefer the mechanisms the project already uses, such as tmux, docker compose, systemd, npm script, etc.

Step 6: Self-check before writing

Check before saving:

  • The file path is strictly .pi/prompts/prompt:<slug>.md。
  • After removing .md from the filename, it is the expected /prompt:<slug>。
  • frontmatter has at least a clear description。
  • When there are parameters, write argument-hint, and make sure the body actually consumes these parameters.
  • Transient values such as versions, IDs, PIDs, tokens, and device lists have not been incorrectly hardcoded.
  • Every key step comes from user requirements, verified traces, or current project evidence.
  • There is clear and executable success verification.
  • The prompt can be understood independently in a brand-new session, without relying on contextual references such as "just now," "above," or "this time."

Step 7: Write and verify

After writing, re-read the file and check:

.pi/prompts/prompt:<slug>.md

If the current Pi session has already started and the new prompt has not yet appeared in completions, prompt the user to run:

/reload

Then it can be accessed via:

/prompt:<slug> ...

Call.

Finally, report only:

  • The created/updated file path
  • The corresponding slash command
  • Which key reusable rules were extracted
  • Which one-off data were parameterized or changed to runtime discovery

Naming examples

Workflow File Command
Publish Dyncode package .pi/prompts/prompt:publish-dyn.md /prompt:publish-dyn
Start development service .pi/prompts/prompt:start-dev-services.md /prompt:start-dev-services
Deploy development device .pi/prompts/prompt:deploy-devices.md /prompt:deploy-devices
Database migration .pi/prompts/prompt:migrate-db.md /prompt:migrate-db

If the name given by the user already has prompt:, do not repeat the prefix.