System Prompts & Engineering
Relevant source files
The following files were used as context for generating this wiki page:
System Prompts & Engineering within the bl1nk platform constitute a multi-layered architecture designed to govern AI behavior, ensure consistent code generation, and facilitate structured development workflows. This system manages various "Chat Modes" (Build, Ask, and Agent) and integrates specialized "Skills" like Kiro and Spec-Kit to transform high-level user ideas into functional, maintainable web applications.
The core objective is to provide an AI editor, bl1nk, that can chat with users, perform real-time code modifications, and adhere to strict technical standards defined in project-specific AI_RULES.md and "Constitutions." By using structured prompts like the THINKING_PROMPT, the system ensures the AI follows a logical analytical framework before performing actions.
Sources: apps/client/src/prompts/system_prompt.ts, plugins/kiro-skill/skills/kiro-skill/SKILL.md, specs/main/plan.md
Prompt Modes & Architecture
The system utilizes different prompt sets based on the user's current intent, defined as chatMode. Each mode has a distinct primary directive and behavioral constraints.
Mode Definitions
| Mode | Purpose | Primary Directive |
|---|---|---|
| Build | Real-time app creation/editing | Modify files using <bl1nk-write> tags; strictly responsive design. |
| Ask | Technical guidance & learning | NO CODE PRODUCTION. Conceptual explanations only. |
| Agent | Research & Requirement Analysis | Identify APIs and resources needed. No code generation. |
Sources: apps/client/src/prompts/system_prompt.ts:250-327
Mode Selection Flow
The following diagram illustrates how the system selects the appropriate prompt based on user settings and mode flags:
This flow describes the logic within constructSystemPrompt and getSystemPromptForChatMode.
Sources: apps/client/src/prompts/system_prompt.ts:329-359
Structured Thinking Process
Before generating any user-facing response, the AI is mandated to use a <think> block. This process is enforced by the THINKING_PROMPT to ensure all relevant factors are considered.
Thinking Framework Components
- Identification: Pinpoint specific UI/FE bugs or feature requirements.
- Examination: Review relevant components and files in the existing codebase.
- Diagnosis: Identify potential causes or architectural needs.
- Planning: Step-by-step breakdown of the proposed approach.
- Refinement: Consider long-term improvements beyond the immediate request.
Sources: apps/client/src/prompts/system_prompt.ts:8-51
Skill-Specific Prompt Engineering
Specialized skills integrate their own workflows and governing principles into the system prompt structure, often utilizing a "Constitution-Based" development model.
Spec-Kit Workflow (7 Phases)
Spec-Kit follows a rigorous lifecycle to move from principles to implementation:
- Constitution: Establish project values and technical standards in
.specify/memory/constitution.md. - Specify: Define functional requirements technology-agnostically.
- Clarify: Resolve ambiguities with targeted questions (max 5 per round).
- Plan: Technical implementation strategy (C4 models, ERDs).
- Tasks: Actionable task generation.
- Analyze: Consistency and quality validation.
- Implement: Systematic execution of tasks.
Sources: plugins/spec-kit-skill/skills/spec-kit-skill/SKILL.md:10-25
Kiro Development Loop
Kiro uses a state-driven loop focusing on EARS (Easy Approach to Requirements Syntax) for acceptance criteria.
The Kiro workflow emphasizes explicit user approval via userInput tool before transitioning between requirements, design, and implementation.
Sources: plugins/kiro-skill/commands/kiro/spec.md:386-410, plugins/kiro-skill/skills/kiro-skill/SKILL.md:195-212
Execution Tags & Constraints
The Build Mode utilizes a set of mandatory XML-like tags to interact with the filesystem. The use of standard Markdown code fences (```) for code generation is strictly prohibited and defined as a "CRITICAL FAILURE."
Mandatory Command Tags
| Tag | Action | Usage Example |
|---|---|---|
<bl1nk-write> | Create/Update File | <bl1nk-write path="src/App.tsx">...</bl1nk-write> |
<bl1nk-add-dependency> | Install Packages | <bl1nk-add-dependency packages="lucide-react" /> |
<bl1nk-command> | UI Action | <bl1nk-command type="rebuild"></bl1nk-command> |
<bl1nk-chat-summary> | Set Chat Title | <bl1nk-chat-summary>Adding Nav</bl1nk-chat-summary> |
Sources: apps/client/src/prompts/system_prompt.ts:70-105, apps/client/src/prompts/system_prompt.ts:236-248
Project Rules (AI_RULES.md)
System prompts are dynamically injected with AI_RULES, which define the specific technology stack and architectural constraints of the project.
- Frontend: React, TypeScript, Tailwind CSS, Shadcn/UI.
- Routing: React Router (routes must remain in
src/App.tsx). - File Structure: Pages in
src/pages/, components insrc/components/. - Primary Directive: Always update the main page (
src/pages/Index.tsx) when adding new components so changes are visible in the preview.
Sources: apps/client/src/prompts/system_prompt.ts:255-275
Conclusion
System Prompts & Engineering in this platform serve as the primary control mechanism for AI agents. By enforcing structured thinking, sequential phase-based development (Kiro/Spec-Kit), and strict code-output tagging protocols, the system ensures that generated applications are predictable, maintainable, and aligned with core project principles.
Sources: apps/client/src/prompts/system_prompt.ts, plugins/kiro-skill/skills/kiro-skill/SKILL.md