For the complete documentation index, see llms.txt. This page is also available as Markdown.

Instrumentation Skills

Agent-agnostic skills that add production-grade Triton instrumentation to Apex, LWC, and Flows — one file or a whole org — with a human-reviewed diff first.

Adding good logging to an existing codebase is the least glamorous job in the world. You know what a well-instrumented class looks like — entry-point templates, resume-first transactions, logNow in every catch, dmlResults on partial DML — but hand-applying that pattern to a backlog of hundreds of Apex classes, LWCs, and Flows is a slog nobody volunteers for.

The instrumentation skills do that slog for you. They're a set of portable, agent-agnostic recipes — the Triton conventions plus a step-by-step, human-in-the-loop workflow — that any AI coding agent can follow to read a file, classify its structure, and add convention-following Triton instrumentation, then show you a diff and let you accept, tweak, or skip it before anything is written. Nothing is applied blindly.

Not tied to any one agent. These skills are plain Markdown playbooks that target the Triton 2.0 static API. They were first shipped as Claude Code slash commands under the /pharos: namespace, but the logic is tool-neutral — the same recipe runs in Cursor, GitHub Copilot, Windsurf, the Codex CLI, or any agent you can point at a file. See Running these in your agent below.

The skill catalog

The three per-technology skills are the primitives. Everything else composes them.

Skill
What it does
Page

instrument-apex

Instruments Apex classes and triggers

instrument-lwc

Instruments Lightning Web Components

instrument-flows

Instruments Flow metadata XML

instrument-org

Orchestrates the three across a whole project/org

audit-logging

Read-only coverage & gap report (no writes)

migrate-to-2.0

Mechanically converts 1.x singleton code to the 2.0 static API

setup-standards

Generates CI guardrails and Log_Level__mdt config

For the "point at an org and instrument everywhere" experience, package the whole catalog behind one persona — see The Triton Instrumentation Agent.

Running these in your agent

Each skill is a Markdown file describing a capability. How you invoke it depends on your agent, but the behavior is identical.

Agent
How to run a skill

Claude Code

Copy two folders from the Triton repository into your project: agent-skills/ (the skills) and .claude/commands/pharos/ (the slash commands). Each command reads agent-skills/<skill>.md from the project root, so both must be there. Then call it, e.g. /pharos:instrument-apex <path>.

Cursor

Add the skill as a Command or a Rule, then invoke it from chat, or @-mention the skill file and give it the path.

GitHub Copilot

Reference the skill file in your prompt (or add it to .github/copilot-instructions.md) and ask it to instrument the file.

Windsurf / Codex CLI / others

Point the agent at the skill file and the target path, e.g. "Follow instrument-apex.md to instrument AccountService.cls."

Any agent

Paste the skill's instructions plus the target file and ask it to apply them. The diff-review loop still applies — you approve before anything is written.

Throughout these pages we use the /pharos:instrument-* slash-command form as a concise, readable stand-in for "invoke this skill." Read it as "run the instrument-apex skill on this path" — substitute your agent's own invocation syntax.

The workflow — human in the loop

Every per-file skill runs the same seven-beat loop. The important part is Step 4: the skill never writes to your file until you've seen the diff and said yes.

  1. Step 0 — Prerequisites. Confirm the Salesforce CLI (sf or sfdx) is installed and a default org is connected. The Flow skill additionally verifies that Triton is installed in the target org (its TritonFlow invocable has to exist). If a prerequisite is missing, the skill stops and tells you exactly what to run.

  2. Parse arguments. Read the target path and flags; ask for anything required that wasn't supplied.

  3. Analyze. Read the file and classify its structure — trigger vs. @AuraEnabled controller vs. batch vs. queueable, wired vs. imperative LWC, screen vs. autolaunched Flow — because the transaction and flush pattern differs per structure. This is also where the skill infers the Area.

  4. Apply. Generate the instrumented version in memory, following the 2.0 static API and Triton best practices.

  5. Review the diff — yes / modify / skip. The skill presents a summary plus the key changes. Say yes to apply, modify to give free-form corrections (it re-applies and asks again), or skip to walk away with nothing written.

  6. Write. On yes, the instrumented content is written back to the original file — no new files, no renames.

  7. Optional deploy. If you passed --deploy (or answer yes when asked), the skill runs sf project deploy start for just the file or component directory it touched.

Two rules every skill enforces

  • Cacheable and @wire Apex never stitches through Platform Cache. @AuraEnabled(Cacheable=true) methods — what @wire calls — can't write to Platform Cache, so Triton.withCache() can't carry a transaction id there and the stitch silently breaks. The skills pass transactionId explicitly and call Triton.resumeTransaction(...) on the server instead. See LWC and Apex → With @wire.

  • Per-log data scales with the level. ERROR, WARNING, and INFO logs carry the most context — serialized inputs and state, plus every related record id. DEBUG carries named values only, and FINE/FINER/FINEST stay terse markers. The skills add more low-level tracing points, because Log_Level__mdt decides at runtime which ones are kept, but keep each one lean. Secrets and personal data are never logged at any level: the skills serialize a redacted copy, or leave the field out.

Instrumentation at scale

The single-file loop is the primitive. The real payoff is running it across a backlog — and you no longer have to hand-loop it.

Because the skills follow shared conventions — resume-first transactions, one Area per feature, logNow + rethrow in catches, flush at boundaries — you get consistent instrumentation no matter who (or what) runs them. There are two ways to work at scale:

  • Drive the primitives yourself. Run instrument-apex down a list of classes in a service layer, reusing one --area so the feature groups cleanly; loop an agent over a directory of LWCs or .flow-meta.xml files, reviewing each diff as it comes; add --deploy once you trust the pattern for a batch.

  • Let the orchestrator do it. instrument-org inventories your whole project, prioritizes it using the Legacy Code Logging Rollout strategy, threads one Area per feature across Apex/LWC/Flow, and works the backlog with review checkpoints and batched deploys — then hands you a coverage report.

"Instrument everything" without giving up control. The orchestrator is the closest thing to an "instrument the whole org" button, but it keeps the human-in-the-loop diff at its core: it batches changes and checks in at boundaries instead of writing hundreds of files blindly. You automate the tedious 90% while staying in control of every change. Start with audit-logging to see the map before you drive.

OpenTelemetry readiness

Triton 2.0's distributed tracing — a transaction id that correlates a whole operation, plus Span_Id__c / Parent_Span_Id__c for parent-child structure — gives your logs a shape that maps cleanly onto OpenTelemetry's vocabulary: trace, span, and parent span. The instrumentation skills are how you get that shape everywhere without hand-writing it: the Apex skill threads one transaction id through async hops, the LWC skill's timeBackendCall carries span context across the call, and the Flow skill stitches the Flow leg into the same transaction.

Where to go next

Last updated