Build PascalAI programs and AI agents — agents, flows, BB, skills, clib, MCP, async
ppm install pascalai-specialist
ppm skill install-claude
The second command activates the skill in Claude Code
(copies it into .claude/skills/).
You are a PascalAI specialist. PascalAI is an AI-native programming language with Pascal-inspired syntax that compiles to a Lape scripting VM hosted in Delphi.
program Hello;
begin
LLM_Connect('claude-opus-4-6', GetEnv('ANTHROPIC_API_KEY'));
WriteLn(LLM_Complete('Greet the world in one sentence'));
end.
agent MyAgent;
behavior 'You are a helpful assistant.';
providers begin
primary: 'claude-opus-4-6';
budget: 1000;
end;
on 'handle' do
begin
var R := LLM_Complete('Process: ' + BB.Get('input'));
BB.Set('result', R);
end;
end;
BB.Set('key', value); // store any scalar
var S := BB.Get('key'); // retrieve as string
var N := BB.GetInt('count'); // retrieve as Int64 (default 0)
var F := BB.GetFloat('score'); // retrieve as Double (default 0.0)
BB.Persist(MyRecord); // persist typed record to storage
BB.Restore(MyRecord); // restore from storage
BB.GetNS('ns', 'key'); // read from specific namespace
flow MyFlow;
node Fetch -> Parse -> Summarize;
parallel Fetch -> [Summarize, Classify] -> Merge;
end;
skill FormalTone;
begin
description: 'Use formal language';
behavior: 'Always respond formally and professionally.';
end;
agent MyAgent;
skill apply FormalTone;
on 'handle' do
begin
// FormalTone is automatically prepended to every LLM_Complete call
var R := LLM_Complete('Reply to user');
end;
end;
agent Counter;
goal Increment(N: Integer): Integer;
behaviour cyclic;
begin
BB.Set('count', BB.GetInt('count') + 1);
Sleep(1000);
end;
end;
var H1 := LLM_Async('Summarize chapter 1');
var H2 := LLM_Async('Summarize chapter 2');
var R1 := LLM_Await(H1);
var R2 := LLM_Await(H2);
type
TProduct = record
Name: string;
Price: Double;
end;
var P: Completion<TProduct> := LLM_JSON<TProduct>('Extract product from: ' + text);
WriteLn(P.Value.Name);
Mem_VInit('memory');
Mem_VStore('PascalAI supports agent flows', '{"source":"docs"}');
var Results := Mem_VSearchText('how do flows work', 5);
uses mathutil; // clib package: MathUtil.Square(9)
uses mcp-datetime; // MCP package: MCP_Now()
uses mcp-hash; // MCP package: MCP_SHA256('text')
providers begin
primary: 'claude-opus-4-6';
fallback: 'claude-haiku-4-5';
strategy: 'fallback';
budget: 5000;
end;
transaction do
begin
BB.Set('step', 'A');
BB.Set('count', BB.GetInt('count') + 1);
end;
.pai — PascalAI source.paipkg — PPM package (ZIP)pai.package — package manifest (INI)SKILL.md — skill definitionpai run myprogram.pai
pai run myprogram.pai --debug --debug-port=9229
LLM_Connect before LLM_CompleteInt64 (not Integer) for numeric BB valuesBB.Get always returns string; use BB.GetInt/BB.GetFloat for numericCompletion<T> requires LLM_Connect to be called first