Sync API
Functions for writing prompt files, agent-specific files, and manifest data to disk.
syncPrompts()
All-in-one sync: write Markdown files, agent files, and manifest.
import { syncPrompts } from "prompts-gpt";
const result = await syncPrompts(prompts, {
cwd: process.cwd(),
outDir: ".prompts-gpt",
overwrite: false,
agent: "all", // or "cursor,codex"
});
console.log(result.markdown.written); // string[] — written file paths
console.log(result.agents.written); // string[] — agent file paths
console.log(result.manifest.manifestPath); // string — manifest path
Parameters
| Property | Type | Default | Description |
|---|---|---|---|
prompts | PromptPack[] | — | Prompts to sync |
cwd | string | process.cwd() | Project directory |
outDir | string | .prompts-gpt | Output directory |
overwrite | boolean | false | Overwrite existing files |
agent | string | "all" | Agent targets |
agents | string | "all" | Alias for agent |
writePromptMarkdownFiles()
Write prompt Markdown files only (no agent files or manifest).
import { writePromptMarkdownFiles } from "prompts-gpt";
const { outDir, written, skipped } = await writePromptMarkdownFiles(prompts, {
outDir: ".prompts-gpt",
overwrite: false,
});
writeAgentFiles()
Write agent-specific files for configured targets.
import { writeAgentFiles } from "prompts-gpt";
const { written, skipped, targets } = await writeAgentFiles(prompts, {
cwd: process.cwd(),
agent: "cursor,codex,claude-code",
overwriteAgentFiles: false,
});
Generated Files by Target
| Target | Files |
|---|---|
codex | AGENTS.md (managed block) |
claude-code | CLAUDE.md (managed block) |
cursor | .cursor/rules/prompts-gpt-.mdc, .cursor/commands/prompts-gpt-.md |
vscode | .github/copilot-instructions.md, .github/instructions/prompts-gpt.instructions.md, .vscode/prompts-gpt.code-snippets |
copilot | .github/prompts/prompts-gpt-*.prompt.md |
continue | .continue/rules/prompts-gpt-*.md |
gemini-cli | GEMINI.md (managed block) |
windsurf | .windsurf/rules/prompts-gpt-*.md |
cline | .clinerules/prompts-gpt-*.md |
junie | .junie/guidelines.md (managed block) |
amp | AGENT.md (managed block) |
Managed Blocks
Files using managed blocks (AGENTS.md, CLAUDE.md, etc.) are updated idempotently:
<!-- prompts-gpt:start -->
# Prompts-GPT Agent Instructions
...content managed by prompts-gpt...
<!-- prompts-gpt:end -->
Content outside the managed block is preserved on re-sync.
writePromptManifest()
Write the manifest.json file.
import { writePromptManifest } from "prompts-gpt";
const { manifestPath, manifest } = await writePromptManifest(prompts, {
cwd: process.cwd(),
outDir: ".prompts-gpt",
});
formatPromptMarkdown()
Format a PromptPack as a Markdown string with YAML frontmatter.
import { formatPromptMarkdown } from "prompts-gpt";
const markdown = formatPromptMarkdown({
title: "Security Review",
slug: "security-review",
summary: "Review code for security issues",
category: "Code Review",
promptText: "Review the codebase for...",
// ...other fields
});
Output format:
---
title: "Security Review"
slug: "security-review"
source: "library"
category: "Code Review"
difficulty: "Intermediate"
outputType: "Text"
supportedTools: ["Codex", "Claude"]
tags: ["security", "review"]
---
# Security Review
Review code for security issues
## Prompt
Review the codebase for...
## Variables
- `targetDir`
- `severity`
## Usage Notes
Focus on OWASP Top 10 vulnerabilities.
See Also
- Client API — Pulling prompts from API
- Agent Integrations Guide