Index of every page on this site: llms.txt
All skills
mohasarc avatar

/trace-code-flow

@f5a6c75
Run it yourself

Produce a compact, syntax-highlighted pseudo-code gist that explains how a specific code path, class, module, feature, or subsystem works. Use when the user asks to understand code flow, generate pseudo-code documentation, create a flow-first gist, explain event-driven or async execution, or asks how a file, class, function, feature, or subsystem works with an emphasis on reading the code path rather than a prose architecture document.

Use this Skill: https://skilld.dev/gh/mohasarc/mo-skills/trace-code-flow

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈114 tokens for metadata: the name and description. ≈1.3k when used: this file. ≈217 more on demand in 1 file.

Description uses 5.7% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈457 characters, or 5.7%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Trace Code Flow

Overview

Generate a small pseudo-code artifact that lets the user follow the real execution path from entry point to exit. Preserve source-code truth: loops stay in their owning objects, event buses expand into representative subscribers, and async callbacks are shown as re-entry points.

Workflow

  1. Identify the requested target and output location.
  2. Trace the source before writing.
  3. Write a short syntax-highlighted pseudo-code gist.
  4. Validate source ownership, event fan-out, and async re-entry.

Ask a clarifying question only when target or output location is ambiguous enough to risk writing the wrong artifact. Otherwise infer a conservative output path, usually near existing docs or beside source-related documentation.

Investigation

Start with structure, then read bodies:

  • Use symbol overview tools first when available for typed source files.
  • Use rg to find constructors, call sites, event registrations, subscribers, emitters, timers, callbacks, and external entry points.
  • Read only source ranges needed to confirm flow and ownership.
  • For event-driven code, trace both sides:
    • where listeners subscribe
    • where events/actions dispatch
    • which representative listeners continue the flow
  • For async code, trace where execution leaves and how it re-enters:
    • timers
    • promises/callbacks
    • socket or request handlers
    • queues/jobs
    • delayed bot or retry actions

Do not stop at a pub-sub loop like listeners.forEach(...). Expand it into concrete subscriber examples so the reader knows where to jump next.

Output Shape

Prefer a Markdown file with a fenced code block using the closest real language for syntax coloring:

# Target Gist

```ts
// Read top to bottom.
// Event dispatch expands below, so it is not a dead end.

function mainFlow(input) {
  // 1. Entry point creates/loads runtime object.
  const runtime = createRuntime(input)

  // 2. Plugins/listeners/mechanics attach.
  attachSubscribers(runtime)

  // 3. Runtime starts and owns its loop.
  runtime.start()

  // 4. External events can re-enter later.
  runtime.handleExternalAction(action)
}
```

Keep the final artifact small. Aim for 50-140 lines unless the user explicitly asks for depth. Omit data fields, helper methods, validation branches, and edge cases that do not help the user follow the main flow.

Required Content

Include:

  • a clear starting function such as mainFlow
  • numbered comments for the main path
  • real owner of loops and lifecycle methods
  • separate external entry points such as socket/request actions
  • event dispatch boundaries expanded into representative subscribers
  • async re-entry points at the bottom when they matter
  • only the most important domain-specific branch examples

Do not include:

  • exhaustive method lists
  • long prose explanations
  • every subscriber in a large event bus
  • every guard clause
  • full type definitions
  • implementation details that do not change the mental model

Event-Based Logic

Represent event systems as continuations, not dead ends:

gotAction(action) {
  if (!isAllowed(action)) return
  actionEngine.sendPlayerRequestedAction(action) // jump to ActionEngine
}

class ActionEngine {
  sendPlayerRequestedAction(action) {
    // Every subscriber sees it. Most return immediately.
    ImportantRule.onActionRequest(action)  // action -> next real call
    OtherRules.onActionRequest(action)
  }
}

Then show representative subscriber classes:

class ImportantRule {
  onActionRequest(action) {
    if (action == ImportantAction) runtime.doNextImportantThing()
  }
}

If subscribers can trigger more events, show the callback:

class ImportantRule {
  onActionCompletion(event) {
    if (event == TimerExpired) runtime.handleExternalAction(autoAction)
  }
}

Async Logic

Mark async boundaries explicitly:

// Async re-entry points.
// socket action -> runtime.handleExternalAction(action)
// timer -> runtime.nextLoop()
// delayed bot/retry/job -> runtime.handleExternalAction(generatedAction)

Do not rewrite callback-driven code as a synchronous while loop unless the source actually owns such a loop. If the source uses setTimeout, promises, queues, or callbacks, show wait(() => owner.nextLoop()) or the equivalent re-entry.

Loyalty Rules

  • Keep method names close to source names when they are important navigation anchors.
  • Group unimportant collaborators under names like OtherMechanics, OtherSubscribers, or createControllers.
  • Use comments to explain jump points, not paragraphs.
  • If a source call fans out to dozens of handlers, show 2-4 representative handlers and label the rest as grouped.
  • If a user says a step is confusing, refine the pseudo-code at that step instead of adding prose around it.
  • If the artifact starts feeling large, delete details before adding sections.

Final Check

Before finishing, verify:

  • reader knows exactly where to start
  • every jump point has a next place to go
  • event dispatch expands into concrete continuations
  • async callbacks have re-entry points
  • loop ownership matches source
  • output renders with syntax coloring
  • artifact is shorter than the source explanation it replaces

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 alert4mo3 checks · Risk SAFE
  • Gen Agent Trust Hub4mo

    The trace-code-flow skill is a developer tool designed to analyze codebase execution paths and generate high-level pseudo-code summaries. It uses standard command-line tools for code searching and does not exhibit any malicious patterns or unsafe data handling.

  • Socket4mo

    No alerts

  • Snyk4mo

    Risk: CRITICAL · 1 issue

Signed by skilld at f5a6c75. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last week.

Activeupdated 5 months ago

README badge

README badge for mohasarc/mo-skills/trace-code-flow