Back to .md Directory

AI Artist — Engineering Specification

name: ai-artist-engineering-spec

May 2, 2026
1 downloads
9 views
ai agent llm rag prompt eval claude gemini
View source

name: ai-artist-engineering-spec description: Full 21-section engineering spec — contracts, deterministic design, compliance matrix, production checklist title: "AI Artist --” Engineering Specification" impact: MEDIUM impactDescription: "Moderate improvement to quality or maintainability" tags: engineering, spec

AI Artist — Engineering Specification

Production-grade specification for AI prompt engineering across text and image generation models at FAANG scale.


1. Overview

AI Artist provides structured prompt engineering patterns for AI text generation (Claude, GPT, Gemini) and image generation (Midjourney, DALL-E, Stable Diffusion, Flux). The skill codifies prompt construction into deterministic, composable templates that produce consistent outputs across models and domains.

The skill operates as a knowledge base, not a runtime executor. It does not call external APIs directly. It produces structured prompt artifacts that agents or users submit to target models.


2. Problem Statement

AI prompt engineering at scale faces four quantified problems:

ProblemMeasurementImpact
Prompt inconsistencySame intent produces divergent outputs across sessions40–60% iteration waste on prompt refinement
Domain knowledge fragmentationPrompt patterns scattered across teams/docsDuplicated effort, no institutional learning
Model-specific syntax errorsWrong parameters for target modelFailed generations, wasted API credits
No quality feedback loopNo structured way to track prompt effectivenessCannot measure improvement over time

AI Artist eliminates these by providing versioned, domain-specific prompt templates with model-aware parameter injection.


3. Design Goals

IDGoalMeasurable Constraint
G1Deterministic prompt constructionSame inputs + same template = identical prompt output
G2Model-portable patternsCore prompt structure works across Claude, GPT, Gemini without modification
G3Domain-specific specializationSeparate reference files for code, marketing, image domains (≤ 4 reference files per domain)
G4Minimal iteration cyclesTarget ≤ 3 refinement iterations to reach desired output quality
G5Measurable prompt qualityEvery prompt includes explicit success criteria the output can be validated against

4. Non-Goals

IDExcludedRationale
NG1Direct API calls to LLM/image providersThis skill produces prompts, not API requests; execution is the caller's responsibility
NG2Prompt response evaluationOutput quality assessment is subjective and model-dependent; owned by the caller
NG3Fine-tuning or model trainingOut of scope; requires specialized ML infrastructure
NG4Image post-processingOwned by media-processing skill
NG5Design system generationOwned by studio skill
NG6Token counting or context window managementModel-specific; handled by context-engineering skill

5. System Boundaries

BoundaryOwnedNot Owned
Prompt template constructionPattern composition, parameter injectionAPI submission, response parsing
Domain knowledgeCode, marketing, image prompt patternsBusiness-specific terminology
Model syntaxMidjourney, DALL-E, SD, Flux parametersModel version compatibility tracking
Quality criteriaDefining success criteria in promptsEvaluating whether output meets criteria
Prompt versioningTemplate structure and namingStorage backend, version control system

Side-effect boundary: AI Artist produces text artifacts (prompts). It does not make network requests, modify files outside the prompt output, or interact with any external service.


6. Integration Model

6.1 Agent Contract

Input Schema

Domain: string              # One of: "text" | "image" | "code" | "marketing"
Model: string | null        # Target model: "claude" | "gpt" | "gemini" | "midjourney" | "dalle" | "sd" | "flux" | null
Template: string            # Template type: "role-task" | "subject-style" | "chain-of-thought" | "few-shot"
Parameters: {
  role: string | null       # For text: "You are a [role]"
  context: string | null    # Background, constraints, audience
  task: string              # The specific action to perform
  format: string | null     # Desired output format: "markdown" | "json" | "csv" | "plaintext"
  examples: Array<{input: string, output: string}> | null  # Few-shot examples
  constraints: Array<string> | null  # "Under 150 words", "p95 <200ms", etc.
  # Image-specific:
  subject: string | null    # What to generate
  style: string | null      # Visual aesthetic
  composition: string | null # Framing and layout
  quality: string | null    # Render quality markers
  model_params: object | null # Model-specific: --ar, --style, --seed, etc.
}
contract_version: string    # "2.0.0"

Output Schema

Status: "success" | "error"
Data: {
  prompt: string            # The constructed prompt, ready for submission
  model: string             # Target model the prompt is formatted for
  domain: string            # Domain used
  template: string          # Template applied
  token_estimate: number    # Estimated token count (approximate, ±10%)
  success_criteria: Array<string>  # Measurable criteria extracted from constraints
  metadata: {
    version: string         # Prompt template version
    parameters_used: object # Echo of input parameters for reproducibility
    contract_version: string    # "2.0.0"
    backward_compatibility: string  # "breaking"
  }
}
Error: ErrorSchema | null

Contract Version: 2.0.0 Backward Compatibility: breaking (first hardened version) Breaking Changes: None — new spec for first hardening

Error Schema

Code: string        # From Error Taxonomy (Section 11)
Message: string     # Human-readable, single line
Domain: string      # text | image | code | marketing
Recoverable: boolean

Deterministic Guarantees

  • Same Domain + Template + Parameters = identical prompt output, character-for-character.
  • Template selection is deterministic: no randomization, no A/B selection.
  • Model parameter injection follows fixed ordering rules (subject → style → composition → quality → model_params).
  • Token estimates use a fixed heuristic (4 chars per token for English text); no external API calls.

What Agents May Assume

  • Output prompt is syntactically valid for the specified model.
  • Model-specific parameters (e.g., --ar 16:9 for Midjourney) are injected in the correct position and format.
  • success_criteria contains all measurable constraints from the input, extracted verbatim.
  • The skill is stateless; no prior invocation affects current output.

What Agents Must NOT Assume

  • The generated prompt will produce the desired output from the target model (model behavior is non-deterministic).
  • Token estimates are exact; they are heuristic-based with ±10% variance.
  • Prompt templates are compatible across model versions (model syntax may change across versions).
  • The skill validates prompt content for safety, bias, or policy compliance.

Side-Effect Boundaries

OperationSide Effects
Prompt constructionNone; pure function producing text output
Template lookupRead-only access to rules/ directory
Parameter injectionNone; string interpolation only
Token estimationNone; arithmetic calculation only

6.2 Workflow Contract

Invocation Pattern

1. Select domain (text | image | code | marketing)
2. Choose template (role-task | subject-style | chain-of-thought | few-shot)
3. Provide parameters (role, task, constraints, examples, etc.)
4. Receive constructed prompt
5. Submit prompt to target model (caller's responsibility)
6. Evaluate output against success_criteria (caller's responsibility)
7. If unsatisfactory: refine parameters, re-invoke (max 3 iterations recommended)

Execution Guarantees

  • Prompt construction is synchronous and completes in a single invocation.
  • No background processes, no deferred execution, no callbacks.
  • Output is complete and self-contained; no partial prompts are returned.

Failure Propagation Model

Failure SeverityPropagationWorkflow Action
Invalid domain/templateReturn error to callerFix input parameters
Missing required parameterReturn error to callerSupply missing parameter
Unknown modelReturn error to callerUse supported model or null for generic
Template file missingReturn error to callerVerify skill installation

Failures are isolated to the current invocation. No state carries between invocations.

Retry Boundaries

  • AI Artist does not retry internally. Given deterministic output, retrying the same input produces the same output.
  • Callers should modify parameters between retries to produce different prompt variations.
  • Recommended maximum iterations: 3 per generation task.

Isolation Model

  • Each invocation is stateless and independent.
  • No shared state between invocations, sessions, or agents.
  • Template files are read-only resources.

Idempotency Expectations

OperationIdempotentNotes
Prompt constructionYesSame inputs = same output, always
Template lookupYesRead-only, no mutation
Token estimationYesDeterministic arithmetic

7. Execution Model

3-Phase Lifecycle

PhaseActionOutput
ParseValidate domain, template, parametersValidated input or error
ComposeApply template, inject parameters, format for modelStructured prompt string
EmitReturn prompt with metadata and success criteriaComplete output schema

All phases execute synchronously in a single invocation. There is no async pipeline, no queue, no deferred processing.


8. Deterministic Design Principles

PrincipleEnforcement
No randomizationTemplate selection, parameter ordering, and output formatting are fixed
No external callsPrompt construction uses only local template files and input parameters
No ambient stateEach invocation operates solely on explicit inputs
Fixed parameter orderingImage prompts: subject → style → composition → quality → model_params
Reproducible outputInput parameters are echoed in output metadata for full reproducibility

9. State & Idempotency Model

State Machine

States: IDLE (single state — skill is stateless)
Transitions: None — each invocation is independent

AI Artist maintains zero persistent state. Every invocation starts from a clean state and produces output solely from inputs + template files. This makes the skill fully idempotent: invoking it N times with identical inputs produces N identical outputs.

Template Versioning

  • Templates are versioned via metadata.version in the SKILL.md frontmatter.
  • Template changes that alter output format require a version bump.
  • Callers can pin to a specific version by referencing a specific template revision.

10. Failure Handling Strategy

Failure ClassBehaviorCaller Recovery
Unknown domainReturn ERR_INVALID_DOMAINUse one of: text, image, code, marketing
Unknown templateReturn ERR_INVALID_TEMPLATEUse one of: role-task, subject-style, chain-of-thought, few-shot
Missing required parameterReturn ERR_MISSING_PARAM with field nameSupply the missing parameter
Unknown modelReturn ERR_UNKNOWN_MODELUse supported model or null for generic format
Template file not foundReturn ERR_TEMPLATE_NOT_FOUNDVerify skill installation integrity
Conflicting parametersReturn ERR_PARAM_CONFLICT with conflicting fieldsResolve the conflict
Parameter exceeds length limitReturn ERR_PARAM_TOO_LONG with field and limitShorten the parameter value

Invariant: Every failure returns a structured error. No invocation fails silently or returns a partial prompt.


11. Error Taxonomy

CodeCategoryRecoverableDescription
ERR_INVALID_DOMAINValidationNoDomain is not one of: text, image, code, marketing
ERR_INVALID_TEMPLATEValidationNoTemplate is not one of the supported types
ERR_MISSING_PARAMValidationYesRequired parameter is null or empty
ERR_UNKNOWN_MODELValidationYesModel identifier not recognized; generic format used as fallback
ERR_TEMPLATE_NOT_FOUNDInfrastructureNoReference template file missing from skill directory
ERR_PARAM_CONFLICTValidationYesTwo parameters contradict each other (e.g., format=json + template=subject-style)
ERR_PARAM_TOO_LONGValidationYesParameter exceeds maximum character limit

12. Timeout & Retry Policy

ParameterValueRationale
Execution timeoutN/APrompt construction is synchronous string manipulation; completes in < 50ms
Internal retriesZeroDeterministic output makes retries meaningless for same input
Caller retry limit3 iterations recommendedEach retry should modify parameters to vary output
Template file read timeout1,000 msFilesystem read; fail immediately if file is inaccessible

Retry policy: Zero internal retries. Since output is deterministic, retrying the same input produces the same result. Callers should modify parameters between invocations.


13. Observability & Logging Schema

Log Entry Format

{
  "trace_id": "uuid",
  "skill_name": "ai-artist",
  "contract_version": "2.0.0",
  "execution_id": "uuid",
  "timestamp": "ISO-8601",
  "domain": "string",
  "model": "string|null",
  "template": "string",
  "status": "success|error",
  "error_code": "string|null",
  "prompt_length_chars": "number",
  "token_estimate": "number",
  "duration_ms": "number",
  "parameters_hash": "string"
}

Required Log Points

EventLog LevelFields
Prompt constructedINFOAll fields
Construction failedERRORAll fields + error_code
Template file readDEBUGtemplate path, read duration
Unknown model fallbackWARNrequested model, fallback used

Metrics

MetricTypeUnit
prompt.construction.durationHistogramms
prompt.construction.error_rateCounterper error_code
prompt.output.char_countHistogramcharacters
prompt.output.token_estimateHistogramtokens
prompt.domain.usageCounterper domain
prompt.model.usageCounterper model

14. Security & Trust Model

Content Safety

  • AI Artist does not filter or validate prompt content for safety, bias, or policy compliance.
  • Content moderation is the caller's responsibility before submitting generated prompts to target models.
  • This boundary is explicit: the skill is a prompt construction tool, not a content governance tool.

Credential Handling

  • AI Artist does not store, process, or transmit API keys, tokens, or credentials.
  • Model-specific authentication is the caller's responsibility.

Template Integrity

  • Template files in rules/ are read-only resources.
  • Template modifications require a version bump in SKILL.md frontmatter.
  • No runtime template injection; templates are static files, not user-supplied code.

Input Sanitization

  • User-supplied parameters are interpolated as literal strings into templates.
  • No template evaluation engine (no eval, no code execution from parameters).
  • Parameters containing template syntax markers are escaped before interpolation.

Multi-Tenant Boundaries

  • Each invocation is stateless; no data persists between invocations.
  • No invocation can access parameters or outputs from another invocation.

15. Scalability Model

DimensionConstraintMitigation
ThroughputCPU-bound string manipulationScales linearly with CPU; no bottleneck
ConcurrencyStateless invocationsUnlimited parallel invocations; no shared state
Template storage4 reference files (~8 KB total)Static files; no growth concern
Memory per invocation< 1 MB (prompt + metadata)No accumulation; GC after return
NetworkZero network callsNo external dependency

Capacity Planning

MetricPer InvocationPer Node
CPU< 5 ms computation200,000+ invocations/second (single core)
Memory< 1 MBBound only by concurrent invocations
Disk I/OSingle template file read (~2 KB)Cached by OS after first read
NetworkZeroZero

16. Concurrency Model

ScopeModelBehavior
Within invocationSequentialParse → Compose → Emit, no internal parallelism
Across invocationsFully parallelNo shared state, no locks, no coordination needed
Template accessRead-only sharedMultiple concurrent reads are safe; no write contention

No undefined behavior: Since the skill is stateless with read-only resource access, any level of concurrency is safe by design.


17. Resource Lifecycle Management

ResourceCreated ByDestroyed ByMax Lifetime
Prompt stringCompose phaseCaller (after consumption)Invocation scope
Template file handleParse phaseEmit phase (auto-close)< 10 ms
Input parametersCallerInvocation completionInvocation scope
Output metadataEmit phaseCaller (after consumption)Invocation scope

Leak prevention: All resources are scoped to a single invocation. No persistent handles, connections, or buffers.


18. Performance Constraints

OperationP50 TargetP99 TargetHard Limit
Full prompt construction< 5 ms< 20 ms50 ms
Template file read< 1 ms< 5 ms1,000 ms
Token estimation< 1 ms< 1 ms5 ms
Output prompt size (text)≤ 500 chars≤ 2,000 chars10,000 chars
Output prompt size (image)≤ 200 chars≤ 500 chars2,000 chars

19. Operational Risks

RiskLikelihoodImpactMitigation
Model syntax changesMediumPrompts use outdated parametersVersion model syntax in rules/model-syntax.md; update on model releases
Prompt injection via parametersMediumMalicious content in generated promptsCaller responsibility; AI Artist does literal interpolation, not evaluation
Template file corruptionLowConstruction failuresERR_TEMPLATE_NOT_FOUND; re-install skill from source
Over-reliance on token estimatesHighPrompts exceed model context windowEstimates are ±10%; callers must validate against actual model limits
Domain pattern stalenessMediumPatterns become less effective over timePeriodic review cycle; version bumps signal updates

20. Compliance with skill-design-guide.md

RequirementStatusEvidence
YAML frontmatter completename, description, metadata with category, version, triggers, coordinates_with, success_metrics
SKILL.md < 200 linesEntry point SKILL.md under 200 lines; details in rules/
Prerequisites documentedNo external dependencies required
When to Use sectionDomain-based decision matrix
Quick Reference with patternsLLM and image prompt patterns with examples
Core content matches skill typeExpert type: domain knowledge tables, prompt patterns
Troubleshooting sectionProblem/solution table
Related sectionCross-links to studio, media-processing
Content Map for multi-fileLinks to 4 reference files + engineering-spec.md
Contract versioningcontract_version, backward_compatibility, breaking_changes
Compliance matrix structuredThis table with ✅/❌ + evidence

21. Production Readiness Checklist

CategoryCheckStatus
FunctionalityAll 4 domains (text, image, code, marketing) specified
FunctionalityAll 4 templates (role-task, subject-style, chain-of-thought, few-shot) specified
Functionality7 model targets specified with fallback behavior
ContractsInput/output/error schemas defined
ContractsAgent assumptions and non-assumptions documented
ContractsWorkflow invocation pattern specified
FailureError taxonomy with 7 categorized error codes
FailureNo silent failures; every error returns structured response
FailureRetry policy: zero internal retries, caller-owned
DeterminismSame inputs = same output guaranteed
DeterminismNo randomization, no external calls, no ambient state
SecurityNo credential handling; no content filtering (explicit boundary)
SecurityInput sanitization: literal interpolation, no eval
ObservabilityStructured log schema with 4 log points
Observability6 metrics defined with types and units
PerformanceP50/P99 targets for all operations
ScalabilityStateless; unlimited parallel invocations
ConcurrencyNo shared state; read-only template access
ResourcesAll resources scoped to invocation lifetime
IdempotencyFully idempotent — all operations are pure functions
ComplianceAll skill-design-guide.md sections present


🔗 Related

FileWhen to Read
image-prompts.mdImage generation techniques
domain-marketing.mdMarketing copy patterns
domain-code.mdCode generation patterns
model-syntax.mdModel-specific parameters
../SKILL.mdQuick reference and anti-patterns

⚡ PikaKit v3.9.162

Related Documents