Expert guidance for Plang programming language (plang.is)...
Plang is a natural language programming language that uses pseudo-code syntax and goal-based architecture. Each file represents a "goal" containing steps written in natural language. Use this skill when working with Plang code generation, debugging, or architectural guidance.
For comprehensive syntax and examples, read the appropriate reference files:
Goals are Plang's fundamental unit. Each goal is a file containing steps:
GoalName
- step 1 description
- step 2 description
- step 3 description
Steps are written in natural language with specific patterns Plang recognizes:
ProcessOrder
- select * from orders where id=%orderId%, return 1, write to %order%
- if %order% is empty then
- throw "Order not found"
- call goal ValidateOrder
- update orders set status='processed' where id=%orderId%
%variableName% syntax throughouton error clauses and validationGenerate Plang goals when the user:
CreateUser ✓ Clear, action-oriented
ProcessPayment ✓ Verb + noun pattern
GetUserData ✓ Specific purpose
DoStuff ✗ Too vague
Main ✗ Not descriptive
✓ %userId%
✓ %order.id%
✓ %user.email%
✓ %request.body.name%
✓ %Settings.ApiKey%
✓ %now%
✗ userId (missing % delimiters)
✗ %user-id% (use camelCase or underscores)
✓ - select * from users where id=%userId%, return 1, write to %user%
✓ - insert into orders, status='pending', amount=%total%, write to %orderId%
✓ - update products set price=%newPrice% where id=%productId%
✗ - query the users table (too vague)
✗ - get user by id (missing proper syntax)
For complex operations, break into sub-goals with option of parameters:
ProcessOrder
- call goal ValidateOrder
- call goal CalculateTotal id=%contractId%
- call goal CreateTransaction
- call goal SendConfirmation
ProcessPayment
- begin transaction "users/%userId%"
- insert into orders ...
- insert into orderItems ...
- call goal ChargeCard
on error call RollbackOrder
- end transaction
CreateRecord
- insert into table, field1=%value1%, field2=%value2%, write to %id%
ReadRecord
- select * from table where id=%id%, return 1, write to %record%
UpdateRecord
- update table set field=%newValue% where id=%id%
DeleteRecord
- delete from table where id=%id%
CallExternalApi
- post %Settings.ApiUrl%/endpoint
headers:
"X-API-key": "%Settings.ApiKey%"
data: {
"field": "%value%"
}
on error call HandleApiError
write to %result%
HandleFormSubmission
- validate %request.body.email% is not empty, "Email required"
- validate %request.body.amount% is not empty and larger than 0
- insert into submissions, email=%request.body.email%, amount=%request.body.amount%
- [ui] render "success.html", navigate
ImportCSV
- read data.csv, first row is header, write to %rows%
- foreach %rows% call ProcessRow item=%row%
ProcessRow
- insert into imported_data, column1=%row.header1%, column2=%row.header2%
Variable not found:
write to %varName%Database errors:
Goal not found:
HTTP errors:
on error status code = 404, call HandleNotFound- write out "Debug: %variableName%"
- write out to system "System log: %value%"
- write out to user log "User-visible message"
Organize by feature domain:
/user/
Create.goal
Login.goal
Update.goal
/order/
Create.goal
Process.goal
Cancel.goal
/payment/
Charge.goal
Refund.goal
Events
- before each goal(including private) in /admin/.*, call CheckAdmin
- on app error, call goal HandleError
- before each goal in /api/.*, call RateLimitCheck
/ Setup.goal - 'data' datasource created automatically
Setup
- create table.....
/ Analytics.goal
Analytics
- create datasource "analytics"
- create table.....
/ UserSetup.goal
UserSetup
- create datasource "users/%userId%"
- create table.....
Query
- select * from main.orders o join analytics.analysis a on a.orderId=o.id
datasource: "data", "analytics"
write to %results%
Note: For sqlite, attaching two datasource, the first datasource uses main. prefix
This skill includes comprehensive reference documentation:
Complete syntax reference covering:
Proven implementation patterns:
Database schema patterns:
Here's a complete example showing best practices:
CreateOrder
- validate %user.id% is not empty, "User must be logged in"
- validate %cart% is not empty, "Cart cannot be empty"
- begin transaction "users/%user.id%"
- insert into orders, status='pending',
amount=%cartTotal%, created=%now%
write to %orderId%
- foreach %cart% call CreateOrderItem item=%cartItem%
- call goal ProcessPayment
on error call HandlePaymentError
- update orders set status='paid' where id=%orderId%
- end transaction
- call goal SendOrderConfirmation
- [ui] render "order_success.html", navigate
CreateOrderItem
- insert into orderItems, orderId=%orderId%,
productId=%cartItem.productId%,
quantity=%cartItem.quantity%,
price=%cartItem.price%
This example demonstrates: