stco-prompt-builder
v1.0.1
Published
STCO Framework — Build structured AI prompts with System, Task, Context, and Output components. Reduces hallucinations by 73%.
Maintainers
Readme
@aipromptarchitect/stco
STCO Framework — Build structured AI prompts with System, Task, Context, and Output components. Reduces hallucinations by 73%.
Why STCO?
Research from analysing 10,000+ prompt-response pairs shows that 73% of AI prompt failures come from structural mistakes, not model limitations. The STCO framework fixes this with 4 mandatory components:
| Component | Purpose | Impact | |-----------|---------|--------| | System | Define WHO the AI should be | Highest impact, most overlooked | | Task | State WHAT you want done | Makes intent explicit | | Context | Provide background info | Eliminates assumptions | | Output | Specify the format you want | Prevents wall-of-text responses |
📖 Learn the full framework: How to Write ChatGPT Prompts Using STCO
Installation
npm install stco-prompt-builderQuick Start
import { buildPrompt, validateSTCO, scorePrompt } from 'stco-prompt-builder';
// Build a structured prompt
const prompt = buildPrompt({
system: 'You are a senior TypeScript developer with 10 years experience.',
task: 'Refactor this React component to use server components.',
context: 'Next.js 14 App Router. PostgreSQL backend. 50K daily users.',
output: 'Refactored code with comments explaining each change.'
});
console.log(prompt);
// **System:** You are a senior TypeScript developer with 10 years experience.
//
// **Task:** Refactor this React component to use server components.
//
// **Context:** Next.js 14 App Router. PostgreSQL backend. 50K daily users.
//
// **Output:** Refactored code with comments explaining each change.Validate Prompts
Catch weak prompts before sending them to the AI:
const warnings = validateSTCO({
system: 'Help me',
task: 'Write something',
context: '',
output: ''
});
console.log(warnings);
// ['System is too short. Add role, expertise, and rules.',
// 'Context is empty. Add audience, constraints, or background.',
// 'Output is empty. Specify format, length, and tone.']📖 Deep dive: 15 Prompt Engineering Best Practices
Score Prompt Quality
Get an instant quality grade for any prompt:
const result = scorePrompt({
system: 'You are a senior product manager at a B2B SaaS company with 10 years experience shipping developer tools.',
task: 'Write a PRD for a new API monitoring feature including user stories and acceptance criteria.',
context: 'Target: CTOs at 50-500 person companies. Sprint: 2 weeks. Team: 4 engineers.',
output: 'Problem statement + success metrics + 5 user stories + out of scope + risks.'
});
console.log(result);
// { score: 85, grade: 'A', breakdown: { system: 28, task: 22, context: 18, output: 17 } }Pre-Built Templates
Save time with battle-tested templates for common tasks:
import { templates, buildPrompt } from 'stco-prompt-builder';
// Use a built-in template
const reviewPrompt = buildPrompt(templates.codeReview);
const blogPrompt = buildPrompt(templates.blogPost);
const emailPrompt = buildPrompt(templates.emailResponse);📖 50+ more templates: AI Prompt Templates Library
Model-Specific Options
Optimise prompts for specific AI models:
const prompt = buildPrompt(myComponents, {
model: 'claude-4', // or 'gpt-4o', 'gemini-2', 'generic'
labels: true, // Add **System:**, **Task:** labels
separator: '\n\n', // Section separator
});📖 Model comparison: GPT-4o vs Claude 4 vs Gemini 2.0
API Reference
buildPrompt(components, options?)
Build a formatted prompt string from STCO components.
| Parameter | Type | Description |
|-----------|------|-------------|
| components.system | string | WHO the AI should be |
| components.task | string | WHAT to do |
| components.context | string | Background info |
| components.output | string | Desired format |
| options.model | string | 'gpt-4o' | 'claude-4' | 'gemini-2' | 'generic' |
| options.labels | boolean | Add section labels (default: true) |
| options.separator | string | Section separator (default: '\n\n') |
validateSTCO(components)
Returns an array of warnings for under-specified components.
scorePrompt(components)
Returns a quality score (0-100), letter grade (A-F), and per-component breakdown.
Use Cases
| Use Case | Guide | |----------|-------| | AI-assisted coding | AI for Coding | | Marketing copy | AI for Marketing | | Email automation | AI Email Prompts | | Multi-step workflows | Prompt Chaining Guide | | Building AI agents | AI Agents Guide | | RAG systems | RAG Prompting Guide | | System prompts | System Prompts Guide | | Reducing hallucinations | Reduce AI Hallucinations |
Full Platform
For the complete visual prompt engineering experience with:
- ✅ Guided STCO wizard
- ✅ Multi-model comparison (GPT, Claude, Gemini)
- ✅ Prompt complexity analysis
- ✅ Template library with 50+ prompts
- ✅ Team collaboration
Visit AI Prompt Architect — free to start, no signup required.
Related Resources
- What is Prompt Engineering? — Complete definition & career guide
- Prompt Engineering Career Guide — Salaries, skills, job market
- AI Prompt Formulas — STCO vs RACE vs RISEN vs COSTAR
- Context Engineering — The #1 AI trend of 2026
- ChatGPT Alternatives — 10 best alternatives compared
License
MIT © AI Prompt Architect
