Not loaded · from iris-dev
Provides ObjectScript loop patterns including For/While, $Order iteration, postfix Quit, and Return vs Quit. Use when writing loops, iterating globals or collections, or handling early exits.
Claude Code won't load this skill
It ships in iris-dev at skills/, but Claude Code only loads skills/<name>/SKILL.md and folders listed under skills in plugin.json. Installing the plugin doesn't add it.
// Quit with a value inside a For/While block is not allowed. The class compiles, and the
// Quit fails at runtime with <COMMAND>. Inside Try/Catch the compiler rejects it:
// ERROR #1043 QUIT argument not allowed. (Both verified on IRIS 2026.2.)
// WRONG — Quit 0 inside For: <COMMAND> when a match is found:
ClassMethod IsUnique(name As %String, lst As %ListOfDataTypes) As %Boolean
{
For i=1:1:lst.Count() {
If (lst.GetAt(i) = name) {
Quit 0 // <COMMAND> at runtime, not a return value
}
}
Quit 1 // only reached after loop completes
}
// CORRECT — Return always exits the method:
ClassMethod IsUnique(name As %String, lst As %ListOfDataTypes) As %Boolean
{
For i=1:1:lst.Count() {
If (lst.GetAt(i) = name) {
Return 0 // exits method immediately with 0
}
}
Return 1
}
// Iterate all keys of a local array:
Set key = ""
For {
Set key = $Order(arr(key))
Quit:key="" // ← postfix Quit, NO SPACES around =
// process arr(key)
}
// WRONG — spaces in the postfix condition:
Quit:key = "" // ← ERROR #1054 Invalid expression
// Fine — a postfix Quit can share a line (verified on IRIS 2026.2):
Set key = $Order(arr(key)) Quit:key=""
// Remove items during iteration — always go backwards:
For i=items.Count():-1:1 {
If (items.GetAt(i) [ "DELETE") {
Do items.RemoveAt(i)
}
}
// items.Count():-1:1 means start=Count(), step=-1, end=1
// Forward iteration:
Set key = $Order(^MyGlobal("")) // "" seed gives FIRST key
While key '= "" {
// process ^MyGlobal(key)
Set key = $Order(^MyGlobal(key))
}
// WRONG — no subscript:
Set key = $Order(^MyGlobal) // ← <FUNCTION> error!
// Reverse iteration:
Set key = $Order(^MyGlobal(""), -1) // last key first
While key '= "" {
Set key = $Order(^MyGlobal(key), -1)
}
// Count up:
For i=1:1:10 { ... } // 1,2,3,...,10
// Count down:
For i=10:-1:1 { ... } // 10,9,8,...,1
// Infinite with explicit Quit:
For {
// ...
Quit:condition
}
// Over a comma-separated list (not common but valid):
For i=1,3,7 { write i,! } // 1, 3, 7
When escaping HTML, always escape & FIRST:
// WRONG — & escaped last causes double-escaping:
// "<b>A & B</b>" → "<b>A & B</b>" → "<b>A & B</b>" ← wrong
// CORRECT — & first:
Set safe = $REPLACE(message, "&", "&") // 1. ampersands first
Set safe = $REPLACE(safe, "<", "<") // 2. then less-than
Set safe = $REPLACE(safe, ">", ">") // 3. then greater-than
// optional: Set safe = $REPLACE(safe, """", """)
// WRONG — modifying i inside the loop causes skipped/repeated iterations:
For i=1:1:items.Count() {
If condition { Set i = i + 1 } // skips next item — DON'T DO THIS
}
// CORRECT — use a separate flag or backwards iteration:
Set i = 1
While i <= items.Count() {
If condition {
Do items.RemoveAt(i) // don't increment — list shrunk
} Else {
Set i = i + 1
}
}
// OR — backwards loop (simpler):
For i=items.Count():-1:1 {
If condition { Do items.RemoveAt(i) }
}
## 8. Global Negative-Key Trick — Descending Sort Without a Sort Step
IRIS globals sort subscripts ascending by default. To iterate in descending order
by a numeric score, store the **negated** value as the subscript key. `$Order` then
visits higher scores first.
```objectscript
// Store: negate the score so high scores sort first
Set ^||TagScores(-score, tag) = ""
// Iterate descending — $Order walks negative numbers most-negative first,
// so -100, -90, -80 ... means scores 100, 90, 80 ...
Set key = ""
For {
Set key = $Order(^||TagScores(key))
Quit:key=""
Set tag = $Order(^||TagScores(key, ""))
Write "Score: ", (-key), " Tag: ", tag, !
}
// Two-level subscript: ^||Name(-score, tiebreaker) = value
// Lets you sort by score descending, then alphabetically within the same score:
Set ^||Results(-score, name) = data
Why it works: IRIS collates numeric subscripts in numeric order. Negative numbers
sort before zero, so -100 < -90 < 0. Negating the score inverts the order.
No $SortBegin / array copy / post-sort needed — the global IS the sorted structure.
Common uses: leaderboards, top-N queries, priority queues, ranked results.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub intersystems-community/iris-agentic-dev --plugin iris-dev40 skills in this plugin
/ensemble-productionManage and observe IRIS Interoperability productions — lifecycle, logs, queues, and message tracing. Covers pyprod Python API, ObjectScript Ens.Director, and MCP tool flow./iris-agentic-devConfigure, connect, and troubleshoot the iris-agentic-dev MCP server (iris_execute/iris_query/iris_doc/docs_introspect/kb/etc.) against an IRIS container or instance. Use when its tools return IRIS_UNREACHABLE, when pointing it at a new IRIS, or when a connection edit "isn't taking effect." Covers the .iris-agentic-dev.toml config, live file-watch reload, the OrbStack port-discovery gotcha, and the docker-exec fallback./iris-agentic-dev-setupOther plugins' skills for the same job