Hoc methods recursion

From openreachtech/hora-skills-ort-core · View interactive version

Hoc methods recursion is an AI agent skill from the GitHub repository openreachtech/hora-skills-ort-core. How a recursive method is laid out: the entry point callers reach, the member that recurses behind it, and where the state a recursion carries from call to call is started. Use when writing or reviewing a method that calls itself, or one that walks a tree or another nested structure. The prefix the

How to use this skill

Skill file

Methods: Recursion

How a method that calls itself is laid out, and how the state it carries from one call to the

next is kept out of reach.

A recursion sits behind an entry point of its own

Callers reach a recursion through a plain-named member that does nothing but start it. The

entry point wears no prefix, and the deep~ member behind it stays off the interface —

private wherever it can be. Where the recursion carries an accumulator — a visited list, a

depth, a path — the entry point gives it its initial value, and the deep~ member takes it as

a required parameter.

// The entry point: a plain name on the interface
loadFiles ({
  directoryPath,
}) {
  return this.deepLoadFiles({
    directoryPath,
    visitedPaths: [],
  })
}

// deep~: the member that realizes the recursion
deepLoadFiles ({
  directoryPath,
  visitedPaths,
}) {
  // ...

  return this.deepLoadFiles({
    directoryPath: nextDirectoryPath,
    visitedPaths: [
      ...visitedPaths,
      directoryPath,
    ],
  })
}

JSDoc, as every entry point reached from outside does (see /hoc-jsdoc); the deep~ member

does not, and that is what leaves it out of the published contract. A native # method is

never the means (see /hoc-prohibit-native-features).

never as a default on any signature a caller can reach, so the recursion's internal state is

stated by the member that starts it and by nothing else.

array to collect what every node returns. With that array reachable from outside — the

deep~ member exposed, or the entry point taking it with a default — a caller can hand in an

array that already holds values, and every such case is one more the tests must cover.

Behind the entry point, the only array the recursion ever starts from is the one the entry

point gives it.

it cannot do: called from outside with the accumulator empty, it starts a walk with no

record of where it has been. Requiring the parameter is what states that it is a step,

not a door.

The `deep~` prefix

in front of it wears none. Which member takes the prefix belongs to

/hoc-super-prefix-method-name.

from the entry at a glance, so a default later added to the deep~ member contradicts its own

name, which is what makes the mistake visible.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.