/walkeros:walkeros-understanding-transformersfrom walkeros
Explains walkerOS transformers for event validation, enrichment, and redaction in the pipeline. Covers available packages, chaining, and integration points.
Ships in walkeros. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Transformers are middleware for validating, enriching, and redacting events in the walkerOS pipeline. They run in chains at configurable points between sources, collector, and destinations.
Core principle: Transformers transform events. They don't capture (sources) or deliver (destinations); they modify events in-flight.
| Use Case | Purpose | Example |
|---|---|---|
| Validate | Ensure events match schema contracts | JSON Schema validation |
| Enrich | Add server-side data to events | User segments, geo data |
| Redact | Remove sensitive data before destinations | Strip PII, anonymize IPs |
| Package | Env | Purpose |
|---|---|---|
@walkeros/transformer-validate | both | Enforce JSON Schema contracts on events at runtime |
@walkeros/transformer-ga4 | both | Decode GA4 Measurement Protocol hits into events |
@walkeros/server-transformer-bot | server | Annotate an automation score and client category |
@walkeros/server-transformer-fingerprint | server | Hash request fields into a rotating visitor id |
@walkeros/server-transformer-file | server | Serve static files from a store |
@walkeros/server-transformer-file owns the paths inside settings.prefix
("/" owns every routed path; without a prefix it owns none). A hit answers
with the file, a miss inside the prefix answers 404, and a failing store read
answers 503. A missing store stops the flow at startup. Route only file requests
to a step that owns /, as flow-complete does with a .js case: any other path
routed to it answers 404 and its event stops there.
@walkeros/transformer-validate is the runtime arm of a
contract. Event shapes
live in the top-level contract block; the transformer references one via
$contract.<name> in its contract setting and validates the canonical event.
mode: "strict" drops invalid events (chain-stop); mode: "pass" (default)
annotates event.source.valid and continues so a downstream step can route on
the verdict. format: true additionally checks the canonical WalkerOS.Event
structure. Filtering is the same mechanism: an inline schema that rejects the
unwanted events plus mode: "strict"; there is no separate ignore field. See
Website: Validate transformer.
See packages/core/src/types/transformer.ts for canonical interface.
Transformers use a context-based initialization pattern:
import type { Transformer } from '@walkeros/core';
export const transformerMyTransformer: Transformer.Init<Types> = (context) => {
const { config = {}, env, logger, id } = context;
// Apply defaults inline: flow.json is developer-controlled, so no
// runtime validation. Shape checks live in ./schemas and are used by
// `walkeros validate` and dev tooling, never at runtime.
const userSettings = config.settings || {};
const settings = {
...userSettings,
// example default: threshold: userSettings.threshold ?? 100,
};
return {
type: 'my-transformer',
config: { ...config, settings },
push(event, pushContext) {
// Process event
return { event };
},
};
};
Init Context contains:
| Property | Type | Purpose |
|---|---|---|
config | Transformer.Config | Settings, mapping, next chain |
env | Types['env'] | Environment deps (stores via $store.) |
logger | Logger | Logging functions |
id | string | Transformer identifier |
collector | Collector.Instance | Reference to collector |
ingest | Ingest | Empty (_meta only); see Push Context |
| Member | Purpose | Required |
|---|---|---|
type | Transformer type identifier | Required |
config | The transformer's config | Required |
push | Process event, return modified/false | Required |
init | One-time initialization | Optional |
destroy | Cleanup resources | Optional |
The push function controls event flow:
| Return | Behavior |
|---|---|
{ event } | Continue chain with modified event |
void | Continue chain, event unchanged |
false | Stop chain, event dropped |
{ event, next } | Route via next in place of its own next, then the chain continues |
{ event, respond } | Continue chain with wrapped respond function |
Result[] | Fork: each result is its own copy with a derived event.id |
A push that throws also stops the chain and drops the event; the collector
logs it and counts it in status.failed. Catch a library error inside push
when the event should continue.
push(event, context) {
if (!event.data?.id) {
context.logger.error('Missing required id');
return false; // Stop chain
}
event.data.enrichedAt = Date.now();
return { event }; // Continue with modified event
}
For simple transformations without external packages, use inline code with the
$code: string prefix in JSON configs. The $code: prefix tells the CLI
bundler to parse the following string as executable JavaScript:
{
"transformers": {
"enrich": {
"code": {
"push": "$code:(event) => { event.data.enrichedAt = Date.now(); return { event }; }"
},
"next": "validate"
}
}
}
Inline code structure:
| Property | Purpose |
|---|---|
code.init | Code run once during initialization |
code.push | Code run for each event |
Push code has access to:
event: the event being processedcontext: push context with logger, config, etc.Return values in push code:
{ event } to continue chain with modified eventundefined to pass event unchangedfalse to drop event from chainExample: Filtering internal events
{
"transformers": {
"filter": {
"code": {
"push": "$code:(event) => { if (event.name.startsWith('internal_')) return false; return { event }; }"
}
}
}
}
Mixing inline and package transformers:
{
"transformers": {
"addTimestamp": {
"code": {
"push": "$code:(event) => { event.data.processedAt = new Date().toISOString(); return { event }; }"
},
"next": "validate"
},
"validate": {
"package": "@walkeros/transformer-validate",
"config": { "settings": { "format": true } }
}
}
}
Transformers run at three points around the collector:
Source → [Source chain] → Collector → [Collector chain] → fan-out → [Destination chain] → Destination
(source.next) (collector.next) (destination.before)
Runs after source captures event, before collector enrichment:
sources: {
browser: {
code: sourceBrowser,
next: 'validate' // First transformer in the source chain
}
}
Runs once per event after collector enrichment, before the destination fan-out.
Every destination receives its output; a stop here (or a transformer returning
false) drops the event for all destinations:
startFlow({
next: ['bot', 'validate'], // collector.next in flow.json
// ...
});
Runs per destination, after the collector chain, before that destination
receives the event. Use it for per-destination work and filtering; a stop here
skips only this destination:
destinations: {
gtag: {
code: destinationGtag,
before: 'redact' // First transformer in the destination chain
}
}
Transformers link together via next. The chain starts at the step that names
its first transformer, here the source:
sources: {
express: {
code: sourceExpress,
next: 'fingerprint' // Chain head
}
},
transformers: {
fingerprint: {
code: transformerFingerprint,
config: {
settings: { salt: process.env.FINGERPRINT_SALT }, // Required
next: 'enrich' // Chain to next transformer
}
},
enrich: {
code: transformerEnrich,
config: { next: 'redact' }
},
redact: {
code: transformerRedact
// No next = end of chain
}
}
Transformers can redirect events to different chains using the branch()
factory from @walkeros/core. The route replaces the transformer's own next
for this event; after it, the enclosing array continues:
import { branch } from '@walkeros/core';
push(event, context) {
return branch(event, 'parser'); // Single target
return branch(event, ['a', 'b']); // Sequence: a, then b
return branch(event, { many: ['a', 'b'] }); // Fork: two copies
return branch(event, { stop: true }); // End this copy
}
Conditional routing is built into the next/before properties through the
one operator, so no router transformer is needed:
"next": {
"one": [
{ "match": { "key": "ingest.path", "operator": "prefix", "value": "/api" }, "next": "apiHandler" },
{ "next": "default" }
]
}
one entries are evaluated in order, first match wins. A RouteConfig is a
disjoint union: each config sets at most one of next (gated link), one
(first-match dispatch), many (all-match fan-out), or stop (drop), never more
than one. Every match reads { ingest, event } and is evaluated when the
event reaches it, so it sees what earlier steps wrote. Besides _meta, ingest
holds only what the source's config.ingest maps and what earlier steps write
into it: without { "map": { "path": "path" } } in that config, ingest.path
is empty and the /api entry never matches. An entry with no match always
matches (use it as a fallback). If no entry matches, the event passes through
unchanged. Use many (allowed in every chain field) when every matching branch
should run: each matching entry becomes an independent copy of the event with
its own derived event.id, and each copy finishes the rest of the path on its
own (never merged):
"next": {
"many": [
{ "match": { "key": "event.consent.analytics", "operator": "eq", "value": "true" }, "next": "ga4Pipeline" },
{ "next": "auditLog" }
]
}
A consent value is a boolean, and eq compares it as text, so a granted consent
matches "true".
walkerOS uses two vocabulary terms for chain composition:
transformers section.code and no package. The runtime synthesizes the push, so the
step contributes structure without shipping executable code.A pass-through step ships in three variants. Each variant uses a different operative field; combine them on the same step when it helps.
A named hop that shares a chain across multiple call sites. Use it to avoid
duplicating arrays in before / next references:
{
"transformers": {
"validateThenEnrich": {
"before": ["validate", "enrich"]
}
},
"destinations": {
"gtag": {
"package": "@walkeros/web-destination-gtag",
"config": { "settings": { "ga4": { "measurementId": "G-DEMO123456" } } },
"before": "validateThenEnrich"
},
"meta": {
"package": "@walkeros/web-destination-meta",
"config": { "settings": { "pixelId": "1234567890" } },
"before": "validateThenEnrich"
}
}
}
A step that declares only a cache block. Useful for deduplication or
short-circuit halts. cache.stop: true in a source chain or collector.next
halts the event for all destinations (not just the local chain); in a
destination.before chain it skips the rest of that chain and the destination
receives the cached event:
{
"transformers": {
"dedup": {
"cache": {
"stop": true,
"rules": [{ "key": ["event.id"], "ttl": 60 }]
}
}
}
}
A step that declares only a mapping: Mapping.Config. The runtime synthesizes a
push that calls processEventMapping and mutates the event in-flight:
{
"transformers": {
"redactPII": {
"mapping": {
"policy": {
"user.email": { "value": "[redacted]" }
}
}
}
}
}
See walkeros-understanding-mapping
for the mapping primitives (policy, data, mapping[].name, etc.) and the
"Mapping at the transformer position" section for the dual semantic.
mapping is the same field shape (Mapping.Config) in both positions, but the
semantic is disambiguated by where the step sits:
| Position | What mapping produces |
|---|---|
| Destination | A vendor-shaped payload (the destination consumes data) |
| Transformer | A mutated event that continues through the chain |
At the transformer position, only event-mutating fields apply: policy, and per
rule condition, policy, name and ignore. consent, include, data
and per rule consent, include, remove, batch, settings, extend,
data, silent do nothing there. A config.mapping wins over the step-level
mapping; next to code or package, a mapping never runs.
walkeros validate and the bundle reject all of these (MAPPING_NO_OP), and
the collector logs one ERROR line for them when the transformer registers.
mapping[].ignore: true drops the event from the chain (not "skip this
destination", which is the destination-position semantic).
Transformer step entries follow a closed schema. Unknown keys at the top of
a step are validation errors (UNKNOWN_KEY; the message lists the allowed keys,
among them package, import, code, config, env, before, next,
cache, state and mapping). This catches misrouted keys (e.g.
{ rules: [], stop: true } placed at the top of a step instead of nested under
cache:) at validate time instead of letting them silently pass through at
runtime.
An empty {} is a valid no-op step. Declaring both code and package on the
same step is rejected with CONFLICT.
Every chain position runs through one runner (runTransformerChain in
@walkeros/collector) over the core continuation stack (startChain /
advanceChain). Routes resolve per hop via getNextSteps(spec, root), which
needs the root { ingest, event } and returns NextSteps: ids (plus a
continuation for the rest of a sequence), a stop, or forks. A member next that
leads back to a step already on its insertion path is skipped, and each copy is
capped at 256 steps. A step listed twice in an array runs twice. An unknown
transformer id is logged as an ERROR line and skipped, and the chain continues;
walkeros validate reports it as an UNKNOWN_ROUTE_TARGET error. Static tools
without an event use getRouteGraph(spec, transformers?), which enumerates
every branch of the same compiled route.
A transformer owns its own chain. When a chain references a transformer by name,
that transformer's own before chain runs before its push, and its next chain
after, both recursively, with cycle detection. This holds inside an explicit
array too: the array is the backbone, and a member's own next is inserted
right after that member before the array continues (["bot", "validate"] with
bot.next = "foo" runs bot, foo, validate). Cache halt signals
(cache.stop: true) in a source chain or collector.next propagate to every
destination. The grammar's recursive Route shape
(string | Route[] | RouteConfig) compiles element-by-element, so sequences can
mix transformer IDs and inline one / many / next routes
(next: ["dedup", { one: [...] }] is valid). This is the model to default to
when adding new chain primitives.
See walkeros-understanding-flow for the full connection rules between sources, transformers, and destinations.
The push function receives a context with event metadata:
| Property | Purpose |
|---|---|
config | Transformer configuration |
env | Environment dependencies |
logger | Scoped logger for output |
id | Transformer identifier |
collector | Access to collector instance |
ingest | Request metadata from source |
push(event, context) {
const { logger, id, ingest } = context;
logger.debug('Processing', { transformer: id, event: event.name });
// Access request metadata if available
if (ingest?.ip) {
event.data = { ...event.data, clientIp: ingest.ip };
}
return { event };
}
Transformers can customize HTTP responses by calling
context.env.respond?.({ body, status?, headers? }). This is useful for
validation transformers that reject events with custom error responses, or
transformers that short-circuit the pipeline. First call wins (idempotent). The
respond function is optional, only present when the source provides one.
| Path | Description |
|---|---|
packages/transformers/ | Transformers for both platforms (validate, ga4) |
packages/server/transformers/ | Server transformers (bot, fingerprint, file) |
state block for fetch/stash without $code:Source Files:
Documentation:
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub elbwalker/walkeros --plugin walkeros22 skills in this plugin
/walkeros-create-cmp-sourceUse when creating a new walkerOS CMP (consent management platform) source. Structured fill-in-the-blanks workflow that turns any CMP's consent API into a walkerOS source package. Covers CookieFirst, Usercentrics, CookiePro/OneTrust patterns and generalizes to any CMP./walkeros-create-destinationUse when creating a new walkerOS destination to send events to a vendor or API (GA4/gtag, Meta/Facebook Pixel, Mixpanel, Amplitude, a custom HTTP API, Measurement Protocol), web or server-side. Example-driven workflow: research the vendor SDK and define step examples before implementing the destination interface, env pattern, and mappings./walkeros-create-sourceUse when creating a new walkerOS source to capture events (browser source, dataLayer interception, server/HTTP source, webhook receiver, event capture), web or server-side. Example-driven workflow: research the input format and define step examples before implementing the push interface, createTrigger, and env pattern./walkeros-create-transformerUse when creating a new walkerOS transformer to modify events in the pipeline (validate, enrich, or redact) at a before/next chain position. Example-driven workflow for the transformer interface, return values, and chaining./walkeros-debuggingUse when walkerOS events aren't reaching destinations, debugging event flow, or troubleshooting mapping issues. Covers common problems and debugging strategies./walkeros-mapping-configurationUse when configuring walkerOS event mappings for specific use cases. Provides recipes for GA4, Meta, custom APIs, and common transformation patterns.Other plugins' skills for the same job