walkeros-create-transformer
Skill354 starsChanged 5 years agoMITView on GitHub
Before starting, read these skills: - understanding-flow - How transformers fit in architecture - understanding-transformers - Transformer interface - understanding-events - Event structure - testing-strategy - How to test - writing-documentation - Documentation standards (for Phase 7) This skill includes reference files you can copy: - templates/validation/ - Complete redact transformer template - index.ts - Implementation with context pattern - types.ts - Type definitions - schemas.ts - Zod settings schema - index.test.ts - Test suite with helpers, one test per…
In this repository22 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- walkeros-create-cmp-sourceSkill
- walkeros-create-destinationSkill
- walkeros-create-sourceSkill
- walkeros-debuggingSkill
- walkeros-mapping-configurationSkill
- walkeros-mcp-actionsSkill
- walkeros-testing-strategySkill
- walkeros-understanding-destinationsSkill
- walkeros-understanding-developmentSkill
- walkeros-understanding-eventsSkill
- walkeros-understanding-flowSkill
- walkeros-understanding-mappingSkill
- walkeros-understanding-sourcesSkill
- walkeros-understanding-storesSkill
- walkeros-understanding-transformersSkill
- walkeros-using-cliSkill
- walkeros-using-loggerSkill
- walkeros-using-step-examplesSkill
- walkeros-using-store-cacheSkill
- walkeros-using-transformer-ga4Skill
- walkeros-writing-documentationSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 3 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
Before starting, read these skills:
- Very specific: line 110
Write one step example per case in src/examples/step.ts: events that pass through (modified or not), the expected output after processing, …
- Very specific: line 196
Every walkerOS package ships a walkerOS.json file for CDN-based schema discovery.
- Very specific: line 212
Keep buildDev() in the defineConfig array (the template package's tsup.config.ts has it):
- Very specific: line 226
If your transformer has capabilities, behaviors, or troubleshooting patterns not obvious from schemas alone, add hints.
- Distinctive: line 256
Verify every claim against actual implementation before publishing
- Distinctive: line 345
Examples for test data: - Don't hardcode test values
- Very specific: line 346
Return value testing: - Verify event, void, or false returns
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Create a New Transformer
Prerequisites
Before starting, read these skills:
- understanding-flow - How transformers fit in architecture
- understanding-transformers - Transformer interface
- understanding-events - Event structure
- testing-strategy - How to test
- writing-documentation - Documentation standards (for Phase 7)
Transformer Categories
| Category | Purpose | Example |
| Validate | Check event structure/content | JSON Schema, required fields |
| Enrich | Add data to events | Server timestamps, geo data |
| Redact | Remove/mask sensitive data | Strip PII, anonymize IPs |
Process Overview
1. Research → Understand use case (validate/enrich/redact)
2. Examples → Create event before/after examples FIRST
3. Scaffold → Copy template, configure package.json
4. Convention → Add walkerOS.json metadata and buildDev
5. Implement → Build transformer with TDD
6. Test → Verify against example transformations
7. Document → Write READMESupporting Files
This skill includes reference files you can copy:
- templates/validation/ - Complete redact
transformer template
- index.ts - Implementation with context pattern
- types.ts - Type definitions
- schemas.ts - Zod settings schema
- index.test.ts - Test suite with helpers, one test per step example
- conformance.test.ts - The conformance kit on a real collector
- examples/ - The template's examples:
step.ts,events.ts(which its unit tests read) andconfig.ts(sample configs)
Copy them into a package as Phase 3 lays it out: index.ts to
src/transformer.ts, types.ts to src/types.ts, schemas.ts to
src/schemas/index.ts, index.test.ts to src/__tests__/stepExamples.test.ts,
conformance.test.ts to src/__tests__/ and examples/ to src/examples/.
Phase 1: Research
Goal: Understand what the transformer needs to do.
1.1 Define Use Case
- Category: Validate, Enrich, or Redact?
- Input: What events will this process?
- Output: What should change? What should be blocked?
- Configuration: What settings does user need?
1.2 Check Existing Patterns
# Reference implementation
ls packages/server/transformers/fingerprint/
# Transformer types
cat packages/core/src/types/transformer.tsGate: Research Complete
- Category identified (validate/enrich/redact)
- Input/output transformation defined
- Configuration options listed
Phase 2: Create Examples (BEFORE Implementation)
Goal: Define event transformations in dev entry FIRST.
2.1 Scaffold Directory Structure
mkdir -p packages/server/transformers/[name]/src/{examples,schemas}2.2 Step Examples
Write one step example per case in src/examples/step.ts: events that pass
through (modified or not), the expected output after processing, and events that
are blocked (for validators). Each export is one Flow.StepExample:
// examples/step.ts
import type { Flow } from '@walkeros/core';
export const orderPasses: Flow.StepExample = {
title: 'Order passes',
description: 'An order event passes through unchanged.',
in: { name: 'order complete', data: { id: 'ORD-123' } },
out: [
['return', { event: { name: 'order complete', data: { id: 'ORD-123' } } }],
],
};
export const debugFiltered: Flow.StepExample = {
public: false,
description: 'A debug event is dropped.',
in: { name: 'debug test', data: { message: 'noise' } },
out: [['return', false]], // the transformer drops this event
};in is a walkerOS event; out is the ['return', value] effect: the result
the transformer returns ({ event }), or false for an event it drops. A
failure example sets outcome instead (see Phase 6). Set title +
description for public examples; mark test-only fixtures with public: false.
src/examples/index.ts exports them with export * as step from './step';. See
using-step-examples for the Three
Type Zones.
2.3 Export via dev.ts
export * as schemas from './schemas';
export * as examples from './examples';Gate: Examples Valid
- All example files compile (
npm run build) - Can trace: input event → expected output for each example
Phase 3: Scaffold
Template transformer: packages/server/transformers/fingerprint/ (a server
transformer). A platform-neutral transformer lives in packages/transformers/
(for example validate, ga4).
cp -r packages/server/transformers/fingerprint packages/server/transformers/[name]
cd packages/server/transformers/[name]
# Update package.json: name, description, repository.directoryDirectory structure:
packages/server/transformers/[name]/
├── src/
│ ├── index.ts # Main export
│ ├── transformer.ts # Transformer implementation
│ ├── types.ts # Settings, Types interfaces
│ ├── dev.ts # Exports schemas and examples
│ ├── examples/
│ │ ├── index.ts # export * as step from './step'
│ │ └── step.ts # Step examples
│ ├── schemas/
│ │ └── index.ts # Zod schemas for settings
│ └── __tests__/ # stepExamples.test.ts, conformance.test.ts
├── package.json
├── tsconfig.json
├── tsup.config.ts
├── jest.config.mjs
└── README.mdPhase 4: walkerOS.json Convention
Every walkerOS package ships a walkerOS.json file for CDN-based schema
discovery.
Add walkerOS field to package.json
{
"walkerOS": {
"type": "transformer"
},
"keywords": ["walkerOS", "walkerOS-transformer", ...]
}Use buildDev() in tsup.config.ts
Keep buildDev() in the defineConfig array (the template package's
tsup.config.ts has it):
import { buildDev } from '@walkeros/config/tsup';
// In defineConfig array:
buildDev(),It builds src/dev.ts and writes dist/walkerOS.json from the schemas,
examples and hints it exports.
Hints (Optional)
If your transformer has capabilities, behaviors, or troubleshooting patterns not
obvious from schemas alone, add hints. See walkeros-writing-documentation
skill for full guidelines.
Create src/hints.ts:
import type { Hint } from '@walkeros/core';
export const hints: Hint.Hints = {
'validation-behavior': {
text: 'Describes how validation works. See settings schema for options.',
code: [{ lang: 'json', code: '{ "settings": { ... } }' }],
},
};Export from src/dev.ts:
export * as schemas from './schemas';
export * as examples from './examples';
export { hints } from './hints';Guidelines:
- Expand awareness: describe capabilities ("supports X, Y, Z"), don't prescribe one path
- Reference schemas and examples, don't duplicate them
- Verify every claim against actual implementation before publishing
- Key naming: kebab-case, group with prefixes (validation-*, enrichment-*, troubleshoot-*)
- Most transformers don't need hints; schemas and examples cover the common case
Gate: Convention Met
walkerOSfield in package.json withtype: "transformer"buildDev()in tsup.config.ts- Build generates
dist/walkerOS.json - Keywords include
walkerOSandwalkerOS-transformer
Runtime-only npm dependencies
A third-party npm dependency that cannot be ESM-bundled (uses __dirname,
ships a .node binary, etc.) needs no declaration: server bundles are traced
with nft, which copies every file the bundle reaches at runtime. Do not add a
walkerOS.bundle field to package.json: the CLI ignores it and warns
still declares walkerOS.bundle.<keys>; this is ignored. See
walkeros-using-cli: server bundles use nft tracing.
Phase 5: Implement
Now write code to transform examples as expected.
5.1 Define Types
See templates/validation/types.ts for the
pattern. Define Settings and Types interfaces.
5.2 Implement Transformer (Context Pattern)
Transformers use the context pattern - they receive a single context
object containing config, env, logger, id, and collector.
See templates/validation/index.ts for a complete implementation example.
Key patterns:
- Context destructuring: Extract
config,logger,idfrom init context - Settings schema, defaults inline: the Zod schema (see
templates/validation/schemas.ts) describes
the settings for
walkeros validate,walkerOS.jsonand the docs; the transformer applies its defaults inline and does not parse settings at runtime - Push receives pushContext: The
pushfunction gets event + push context - Return values:
{ event }(continue),void(passthrough),false(cancel on purpose: a deliberate drop, not a failure; the push answersok: true), or an array of results to fork the event (see understanding-transformers) - A failure is a throw: throw a
StepErrorfrom@walkeros/corewith acode.missing-inputis the code for an event or an ingest that lacks the input the transformer needs (do not drop it silently);configfor a missing setting.initthrows instead of returningfalseor returning early, and a transformer never logs a failure itself: the collector turns the throw intook: falsewith the transformer named and writes the one ERROR line. A transformer that throws a plain error fails with the codetransformer.
5.3 Export
src/index.ts:
export { transformerRedact } from './transformer';
export type { Settings, Types } from './types';Gate: Implementation Compiles
npm run buildpassesnpm run verify:touched -- <platform>-transformer-<name>passes (L1: typecheck + lint + test; the argument is the package name after@walkeros/,transformer-<name>for a platform-neutral one)
Phase 6: Test Against Examples
Verify implementation produces expected outputs.
See templates/validation/index.test.ts for a complete test suite showing:
createTransformerContext()helper - a typed init context for unit tests, defined in the test filecreatePushContext()helper - the same for the push context- Examples for test data - Don't hardcode test values
- Return value testing - Verify
event,void, orfalsereturns - Conformance -
conformance('transformer', transformer, options)from@walkeros/collector/dev(profiletransformer) runs it on a real collector, seepackages/server/transformers/fingerprint/src/__tests__/conformance.test.ts. A transformer needs nopage. A transformer whose input is the ingest and not an event declares its failure with amissing-inputexample (an event asin,out: [], anoutcomeand a description).
Gate: Tests Pass
npm run verify:touched -- <platform>-transformer-<name>passes (L1)- Tests verify against example outputs
Phase 7: Document
Follow the writing-documentation skill for:
- README structure and templates
- Quality checklist before publishing
Key requirements for transformer documentation:
- Use case description (validate/enrich/redact)
- Configuration options table
- Working code example with imports
- Installation instructions
- Link to website docs
Transformer-Specific Validation
Beyond
understanding-development
requirements (build, test, lint, no any):
dev.tsexportsschemas(withsettings;z.object({})when the step has none) andexamples- Multi-export package (two or more
walkerOS.exports):exportExamplesandexportSchemasindev.tslist exactly those exports, the default included, and everyexportSchemasentry hassettings; the build fails otherwise (see using-step-examples) - Examples include before/after event pairs
- Return values handle all cases (event, void, false)
- A failure is a thrown
StepError(missing-inputfor absent input),initthrows instead of returningfalse, conformance test passes - Tests use examples for assertions (not hardcoded values)
walkerOS.jsongenerated at build timewalkerOSfield in package.json
Reference Files
| What | Where |
| Template | packages/server/transformers/fingerprint/ |
| Types | packages/core/src/types/transformer.ts |
| Chaining logic | packages/collector/src/transformer.ts |
Related Skills
- walkeros-understanding-transformers - Transformer interface and chaining
- walkeros-testing-strategy - Testing patterns and env mocking
- walkeros-writing-documentation - Documentation standards
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

