Popup YouTube Video
Sheerpower Logo

A Guide for an AI when Vibe Coding


Sheerpower: A Guide for an AI when Vibe Coding

This guide is written for AI language models generating Sheerpower code. It focuses on the patterns most likely to produce incorrect output when models apply habits from C, Python, JavaScript, or Java — and shows the correct Sheerpower form alongside each trap.

Special note:

Generate only syntax that appears in this guide or in the official Sheerpower tutorials. When a statement, function name, parameter, or syntax rule cannot be confirmed from either source, do not invent a plausible-looking substitute. Instead, choose one of the following actions:

  • State the uncertainty in plain text.
    Example: I am not certain whether Sheerpower's string-search function is pos(), index(), or find(). Please confirm before I continue.
  • Request the relevant tutorial or reference material.
    Example: Before writing the file I/O section, I need to re-read the File I/O tutorial. Is it available?
  • Insert a clearly marked gap and continue around it.
    Example:
// UNVERIFIED: exact syntax for sorting a cluster array descending
// confirm against Cluster Sorting tutorial before running

A compile error on a marked gap is recoverable. A confabulated routine name buried in otherwise correct-looking code is not — it fails silently, erodes trust, and can take longer to track down than the original task.

Takeaway: Stop, mark, or ask — in that order. If a piece of Sheerpower syntax cannot be traced to this guide or the tutorials, that is the signal to pause, not proceed.

This document is structured around error patterns observed in generated code — not around language features.

The goal is simple: eliminate predictable errors in generated code before they reach execution.

Human readers will also find this a useful quick-reference for the rules that differ most from mainstream languages.

What this guide covers

  • Comment syntax — // for all new code.
  • Sheerpower Routine calling syntax — no call prefix keyword, use named parameters
  • All with arguments are read-only within the routine — compiler enforced
  • Block terminators — the full list
  • Exception handling — attached vs. detached, retry vs. continue
  • Loop control — do / repeat do / end do
  • Variable suffixes — $, ?, and bare names
  • Cluster access and iteration
  • The VIEW statement
  • What does not exist in Sheerpower
  • Unique IDs — _GID$ special variable
  • Exception handler discipline — when a handler earns its place
  • Routine ordering — major to minor, callers before the routines they call
  • All Sheerpower code must be written using ASCII characters only

Calling Routines

This is the single most common error in AI-generated Sheerpower code. Sheerpower has no call prefix keyword when invoking routines. Routines are invoked by just their name, followed by with for inputs and returning for outputs. Sheerpower routine names cannot contain "$" or "?" characters. All with arguments are read-only within the routine — compiler enforced

Problem: AI models trained on other languages generate call routine_name(args) or result = routine_name(args).

Solution: Use Sheerpower's named-parameter syntax. There is no call keyword and no parentheses on routine invocations.

Efficiency: Named parameters are passed by reference, so even large data structures cost nothing to pass.

Takeaway: Never write call. Never write result = routine_name(args). Use the with / returning syntax below.

Wrong (do not generate)

call calculate_tax(income, rate) tax = calculate_tax(income, rate) calculate_tax(income, rate, tax)

Correct

// Full syntax calculate_tax with income=my_income, rate=tax_rate, returning tax tax_due // Without "=" calculate_tax with income my_income, rate tax_rate, returning tax tax_due // Implied -- variable names match parameter names exactly calculate_tax with income, rate, returning tax

All three forms are equivalent. The implied form works when your local variable names exactly match the routine's parameter names.

Routine definition

routine calculate_tax with income, rate, returning tax tax = income * rate end routine

Parameters are read-only inside the routine by default. Do not attempt to assign to a with parameter — it will not change the caller's variable.

Block Terminators — the Complete List

Every block in Sheerpower has an explicit named terminator. Missing or mismatching a terminator is a common AI error, especially when generating nested structures.

Problem: AI models omit terminators, use wrong keywords, or use braces from C-style habits.

Solution: Most blocks close with a two-word or three-word end ___ keyword — no braces.

Efficiency: Sheerpower's compiler reports the exact line of a missing terminator, making errors easy to find.

Takeaway: After generating any block, verify that its closing keyword appears in the list below.
end routine end handler end when end collect end do end if end select

There are no braces. There is no endif as a single word — it must be written end if with a space.

for loops — both numeric and for each — close with next varname, not an end keyword.

// Numeric for loop for i = 1 to 10 print i next i // closes the for loop // For each over a cluster array for each orders print orders->customer$ next orders // closes the for each loop -- NOT "end for"

Nested structure example — correct terminators

routine process_orders with orders for each orders if orders->amount > 1000 then select case orders->region$ case "North" print "North: "; orders->amount case else print "Other: "; orders->amount end select end if next orders end routine

Exception Handling

Sheerpower has two forms of exception handler. The words retry and continue mean something specific here and must not be confused with loop control.

Attached handler (most common)

when exception in // protected code here x = 10 / y use if extype = exceptiontype("divby0") then y = 1 retry // re-executes the failing statement else print "Error: "; extext$ continue // resumes at the statement AFTER the one that failed end if end when

Detached handler

when exception use fix_divide_error average = total / count end when print "Average: "; average handler fix_divide_error average = 0 continue end handler
Problem: AI models confuse retry and continue, or use throw / raise / except from other languages.

Solution: Use only the Sheerpower keywords shown above. To raise an exception deliberately, use cause exception.

Efficiency: Sheerpower's stackless VM rewinds call depth on exception at near-zero cost, so exception handlers are not expensive.

Takeaway: retry = re-run the failing statement (after fixing the cause). continue = skip the failing statement and move on. Never write throw, raise, except, or catch.

Exception introspection variables

_error // TRUE if an exception occurred extype // numeric exception type extext$ // plain-text description of the exception exlabel$ // source location where the exception occurred systext$ // OS-level error description // Compile-time constant folding -- zero runtime cost when literal string used: exceptiontype("divby0") // returns 3001 exceptiontype("filenotfound") // returns 7110

Causing an exception deliberately

// cause exception takes a numeric exception number if quantity < 1 then cause exception 1001 if quantity < 1 then cause exception exceptiontype("illnum")

Loop Control

Sheerpower's main loop construct is do / end do. The keyword that restarts the loop from the top is repeat do — not continue. The keyword that exits is exit do.

Problem: AI models write continue inside a loop intending to restart the iteration. In Sheerpower, continue is an exception-handler keyword only.

Solution: Use repeat do to restart a do loop. Use exit do to break out.

Efficiency: repeat do is explicit about intent — there is no ambiguity about which loop is being restarted in nested structures.

Takeaway: Inside a loop, never write continue. Write repeat do to cycle, exit do to leave.

Wrong (do not generate)

do input "Enter a positive number": n if n <= 0 then continue // WRONG -- continue is not loop control print n * 2 end do

Correct

do input "Enter a positive number": n if n <= 0 then print "Must be positive. Try again." repeat do // restart the loop end if print n * 2 end do

For loops and for-each

// Numeric for loop for i = 1 to 10 print i next i // Step for i = 10 to 1 step -1 print i next i // Open-ended for loop -- no upper bound; use "exit for" to leave for idx = 1 VIEW token$ INTO data$, PIECE ",", MATCH idx if token$ = '' then exit for print token$ next idx // For each over a cluster array for each orders print orders->customer$; ": "; orders->amount next orders // Exit a for loop early for i = 1 to 100 if results(i) = "done" then exit for next i

Loop control keywords — complete list

Problem: AI models use continue inside for loops (skip to next iteration) or break to exit. Neither keyword exists for loop control in Sheerpower.

Solution: Use the keywords below. Each one is specific to its loop type.

Efficiency: Explicit keywords make it unambiguous which loop is being controlled in nested structures.

Takeaway: iterate for skips to the next for iteration. repeat do restarts a do loop. Never use continue or break for loop control.
// DO loop control repeat do // skip remaining body, restart from top of do loop exit do // exit the do loop entirely // FOR loop control iterate for // skip remaining body, advance to next for iteration exit for // exit the for loop entirely

Early exit from a routine

There is no return statement in Sheerpower. To exit a routine before reaching its end, use exit routine.

routine validate_amount with amount, returning ok? ok? = false if amount <= 0 then exit routine // early exit -- ok? stays false if amount > 1_000_000 then exit routine ok? = true end routine

Variable Naming and Type Suffixes

Sheerpower uses visual suffixes to declare variable type implicitly. These are part of the variable name, not operators.

name$ // STRING -- ends with $ is_active? // BOOLEAN -- ends with ? total // REAL -- no suffix (default numeric type) count // REAL -- REAL holds integers accurately too
Problem: AI models omit the ? suffix on boolean variables, generating is_active = true instead of is_active? = true.

Solution: Any variable holding a boolean value must end with ? when declared implicitly. Without the suffix, Sheerpower creates a REAL variable and true stores as 1.

Efficiency: Suffix-based typing means no var, let, int, or float declarations needed for most cases.

Takeaway: Check every boolean variable name for the ? suffix. Check every string variable name for the $ suffix.

Explicit declarations when needed

declare string shipping_address // explicit string, no $ suffix needed declare real salary // explicit real declare boolean is_manager // explicit boolean, no ? suffix needed declare dynamic x // type determined at first use

Constants

const max_retries = 5 const app_name$ = "OrderSystem"

String Literals — No Escape Sequences

Sheerpower string literals are treated as raw text. There are no escape sequences inside strings.

Problem: AI models trained on C, Python, or JavaScript generate escape sequences such as \n, \t, or \\, or double-escape backslashes unnecessarily.

Solution: In Sheerpower, a string stores exactly the characters written. A backslash is just a backslash. There are no escape rules to apply.

Efficiency: This eliminates an entire class of bugs related to incorrect escaping and double-escaping across systems.

Takeaway: What you type is what is stored. Do not insert extra backslashes. Do not interpret escape sequences.

Example

a$ = "\" // a$ contains exactly one character: "\" b$ = "\n" // contains two characters: "\" and "n"

Do not apply escape rules from other languages. Write exactly the characters you want stored in the string.

Date and Time Functions

Sheerpower has its own date and time functions, and these should be used for all date and time manipulation.

Do not assume date or time syntax from other programming languages.

Before writing any date or time code, note these specific patterns that AIs frequently get wrong in Sheerpower:

  • SECONDS() requires a full datetime string, not just a date. A variable containing only YYYY-MM-DD will cause an illegal time format error.
  • Do not invent formatting helper routines such as format_duration(). Use the built-in date and time functions instead.
  • Do not assume date arithmetic syntax from Python, JavaScript, or any other language.
  • If your code touches dates, times, durations, or time arithmetic in any form, re-read the Date and Time Functions tutorial before writing that section.

To avoid common AI confabulations, read this tutorial carefully before writing or explaining any Sheerpower code that works with dates or times:

Date and Time Functions Tutorial

Clusters — Access and Iteration

Clusters are Sheerpower's primary structured data type. The field-access operator is ->.

Scalar cluster (single record)

cluster employee: name$, age, real salary, position$ employee->name$ = "Maria Santos" employee->age = 34 employee->salary = 62_000 employee->position$ = "Senior Analyst" print employee->name$; " earns "; employee->salary

Cluster array (adding multiple rows)

cluster orders: customer$, amount, region$ add cluster orders orders->customer$ = "Acme Corp" orders->amount = 4500 orders->region$ = "North" add cluster orders orders->customer$ = "Beta LLC" orders->amount = 1200 orders->region$ = "South" add cluster orders orders->customer$ = "Acme LLC" orders->amount = 5500 orders->region$ = "East" add cluster orders orders->customer$ = "Alpha LLC" orders->amount = 2200 orders->region$ = "West"

Collecting and iterating

collect cluster orders include orders->amount > 1000 sort by orders->customer$ end collect for each orders print orders->customer$; tab(25); orders->amount next orders

Descending Sorting

collect cluster orders include orders->amount > 1000 sort descending by orders->amount end collect for each orders print orders->customer$; tab(25); orders->amount next orders
Problem: AI models generate loop variables like for order in orders and then access fields as order->amount. There is no such iteration variable in Sheerpower.

Solution: Inside a for each loop, use the cluster name itself with -> to access fields: orders->amount.

Efficiency: for each iterates the collected result set directly with no temporary object allocation.

Takeaway: The cluster name is both the collection and the current-row accessor. There is no separate iterator variable.

Loading from a CSV file

cluster sales: date$, product$, amount, region$ cluster input name '@sales_2025.csv', headers 1: sales

The VIEW Statement

VIEW creates a zero-copy window into a source string. It does not allocate a new string — it references a position and length within the original buffer. The clauses must appear in the correct order.

Problem: AI models either omit VIEW entirely and generate slow substring loops, or get the clause ordering wrong.

Solution: Use the clause order shown below. INTO names the source. The remaining clauses (MID, PIECE, MATCH, etc.) describe how to locate the window.

Efficiency: No string copy occurs. For large files parsed line-by-line, this is orders of magnitude faster than building substrings in a loop.

Takeaway: When parsing delimited text, reach for VIEW before reaching for mid$() or string concatenation.

Extracting a segment using MID

data$ = "hello" VIEW v$ INTO data$, MID 2, 3 // character positions 2, 3, and 4 // v$ hasn't calculated offsets yet PRINT v$ // NOW it evaluates to "ell" (and caches it) PRINT v$ // Reuses cached offsets - no recalculation! data$ = "world" PRINT v$ // Re-evaluates to "orl" because source changed

Extracting a delimited piece

csv_line$ = "Alice,Santos,42,Manila" VIEW first_name$ INTO csv_line$, PIECE ",", MATCH 1 VIEW last_name$ INTO csv_line$, PIECE ",", MATCH 2 VIEW age$ INTO csv_line$, PIECE ",", MATCH 3 print first_name$; " "; last_name$; " age "; val(age$)

Iterating all pieces in a string

data$ = "red,green,blue,yellow" for idx = 1 VIEW token$ INTO data$, PIECE ",", MATCH idx if token$ = '' then exit for print idx; ": "; token$ next idx

Parsing a file line by line

sep$ = chr$(13) + chr$(10) log$ = fileinfo$("@app.log", "contents") for idx = 1 VIEW line$ INTO log$, PIECE sep$, MATCH idx if line$ = '' then exit for if contains(line$, "error") then print line$ next idx

Keywords That Do Not Exist in Sheerpower

The following keywords are common in other languages. None of them exist in Sheerpower. Generating them will produce a compile error.

// These keywords do not exist in Sheerpower -- do not generate them: call // routines are invoked by name only return // use: exit routine (to exit early) or the "returning" clause (to pass back values) throw // use: cause exception raise // use: cause exception catch // use: when exception in ... use ... end when except // use: when exception in ... use ... end when continue // in loops, use: repeat do / iterate for (continue is for exception handlers only) new // no heap allocation; clusters and variables are declared, not constructed this // no object model; use cluster field access: clustername->field null // use '' for empty string, 0 for empty numeric void // routines with no returning clause simply have no return value function // use: routine ... with ... returning ... def // use: routine fn // use: routine break // use: exit do or exit for end for // for loops close with "next varname", not "end for" endif // must be written as two words: end if

Print and Output

Output uses print. Items are separated by semicolons. A trailing semicolon suppresses the newline. Tab alignment uses tab(n).

print "Hello, "; name$ // basic output print "Total: "; total; " items" // mixed types -- no conversion needed print "Col1"; tab(20); "Col2"; tab(40); "Col3" // tabbed columns print // blank line print "No newline here"; // trailing semicolon suppresses newline print " -- continued on same line"

Formatted numeric output

print sprintf$("%m", 1234567.89) // output: 1,234,567.89 print sprintf$("%.2f", price) // output: 1234567.89 print sprintf$("$%.2m", amount) // output: $1,234,567.89

Input from the User

input "Enter your name": name$ // prompts, reads string or number line input "Enter a sentence": sentence$ // reads entire line including spaces

Use line input when the input may contain spaces or commas. Use input for simple values.

Routine Scoping Rules

Sheerpower has four routine scopes. Generating the wrong scope is a common AI error, especially confusing local and private.

routine name // global -- accessible from anywhere in the program private routine name // module-level -- accessible only within this file scoped routine name // block-scoped -- accessible only within its enclosing routine local routine name // shares the parent routine's variable scope entirely

Sheerpower has no user-defined functions that return values. Instead, it has routines, each of which can return up to 16 values. Sheerpower has many dozens of built-in functions.

Problem: AI models use private when they mean local, or generate a with clause on a local routine that shares the parent's scope.

Solution: A local routine sees all of the parent routine's variables directly. It does not need parameters for data the parent already has. A private routine is isolated and must receive data through parameters.

Efficiency: Local routines avoid parameter overhead when decomposing a large routine into named steps.

Takeaway: If the sub-routine needs to read or write the parent's variables directly, use local. If it is a standalone reusable unit, use private or routine.
private routine process_invoice with inv total = 0 local validate_line_items local apply_discounts local format_output end routine local routine validate_line_items // sees inv, total directly from process_invoice's scope for each inv if inv->qty < 0 then inv->qty = 0 next inv end routine local routine apply_discounts if total > 10_000 then total = total * 0.95 end routine local routine format_output print "Invoice total: "; sprintf$("$%.2m", total) end routine

Unique IDs

Whenever you need a unique ID, use the _GID$ special variable. It returns a 30-character, browser-safe identifier that combines a date stamp and a unique ID. The result is both globally unique and sortable by creation date.

Because _gid$ includes a universally unique identifier (UUID), two instances of the same handler running simultaneously will never produce the same value, even when running on different systems. This eliminates the need for counters, sequence generators, or inter-process coordination.

add table todos todos(id) = _gid$ // globally unique, generated locally todos(status) = 'open' todos(priority) = priority$ todos(description) = desc$ todos(last_datetime) = fulltime$ end add

Exception Handlers

Only wrap code in a when exception in block when you intend to handle the error differently than Sheerpower would on its own. Sheerpower already stops on unhandled exceptions and automatically reports the error type, description, call stack, and source location.

A handler earns its place only when it does something Sheerpower's automatic crash report cannot — such as retrying with a fallback, logging before continuing, or allowing the program to recover and keep running.

No handler needed:
cluster input name '@fruits.csv', headers 1: fruits
Handler earns its place:
when exception in
  cluster input name '@fruits.csv', headers 1: fruits
use
  if extype = exceptiontype('filenotfound') then
    cluster input name '@fruits_default.csv', headers 1: fruits
  else
    stop
  end if
end when
Takeaway: A use block that only prints extext$ and stops gives the user less information than Sheerpower's automatic crash report. Delete it and let Sheerpower handle it.

Routine Ordering — Major to Minor

Order routines so that every routine appears before the routines it calls. The main logic area comes first, then the high-level routines it calls, then the lower-level routines those call, and so on down to leaf routines at the bottom.

Think of it as a newspaper article — headline first, detail later. A reader should be able to start at the top and follow the logic downward without ever needing to jump back up.

// Correct order -- each routine appears before what it calls routine process_orders // high-level: called from main routine validate_order // mid-level: called by process_orders routine save_orders // mid-level: called by process_orders routine format_order_row // low-level: called by save_orders
Problem: Routines written in the order they were created force readers to jump back and forth to follow the logic.

Solution: Order routines top-down. High-level orchestrating routines first, helpers and infrastructure last.

Efficiency: In a large application this makes the file structure encode the call graph. You always know where to look, and you always understand the context of a routine before you reach its implementation.

Takeaway: Before writing a routine, confirm that the routines which call it have already appeared earlier in the file.

Pre-Flight Check for Generated Code

Before submitting generated Sheerpower code, run through this checklist mentally:

  • No "call" keyword anywhere?
  • Routine invocations use "with" and "returning"?
  • Every block (except for ADD CLUSTER) has a matching "end ___" terminator?
  • For loops close with "next varname" -- not "end for"?
  • Boolean variables end with "?"?
  • String variables end with "$"?
  • Loop restart uses "repeat do" (do loops) or "iterate for" (for loops) -- not "continue"?
  • Loop exit uses "exit do" or "exit for" -- not "break"?
  • Early routine exit uses "exit routine" -- not "return"?
  • Exception handler uses "retry" or "continue" -- not "return"?
  • "for each" loops access fields as clustername->field$?
  • No "throw", "raise", "catch", "new", "return", "break", "end for"?
  • VIEW clauses: target INTO source, PIECE delimiter, MATCH index?
  • Cluster routine parameters use root name only -- no colon syntax?
  • No exception handler whose only action is print + stop?
  • Routines ordered major to minor — callers before the routines they call?
  • String literals have no escape sequences. "\n" is two characters: "\" and "n".

(Show/Hide Key Takeaways)
Hide Description

    

       


      

Enter or modify the code below, and then click on RUN

Looking for the full power of Sheerpower?
Check out the Sheerpower website. Free to download. Free to use.