# Millwork > Shapes, values and wire codecs for WarpDrive and ember-data. A codec turns one raw wire > value (JSON) into an immutable value object, such as `Money` or a date, and back. A shape > is a nested object that the app edits in place, with change tracking by path. A value is > immutable: to change it, set a new one. Install `@millwork-ts/core` and `@millwork-ts/warp-drive`. Add one package for each peer library: `@millwork-ts/temporal`, `@millwork-ts/luxon`, `@millwork-ts/date-fns`, `@millwork-ts/dayjs`, `@millwork-ts/dinero`, `@millwork-ts/decimal`, `@millwork-ts/phone`, `@millwork-ts/color`, `@millwork-ts/quantity`, `@millwork-ts/semver`, `@millwork-ts/ip`, `@millwork-ts/rrule`, `@millwork-ts/cron` and `@millwork-ts/geo`. Guide: https://joegaudet.com/millwork/guide/ API reference: https://joegaudet.com/millwork/api/ Full API as text: https://joegaudet.com/millwork/api/llms-full.txt ## Rules for writing code with Millwork 1. Make every codec with `defineCodec({ name, parse, format, isValue, equals })` from `@millwork-ts/core`. Do not write a `Codec` object by hand: `defineCodec` gives the rules for `null`, errors and freezing. `parse` may throw on bad input; `hydrate` then gives `undefined` and a report to `onInvalid`. 2. Never mutate a value. `Money`, dates, `Decimal`, `LatLng` and `Value` instances are immutable. To change a field, set a new value: `record.total = Money.fromDecimal('5.00', 'USD')`. For a `Value` class, use `price.with({ label: 'Sale' })`. 3. Choose shape or value on purpose. A shape (`extends Shape`) is a nested object that a form edits in place, such as an address. A value (a codec value, or `extends Value`) is a quantity that is replaced whole, such as money or a date. Do not use the word "fragment". 4. Every shape and value class has a unique `static override type = 'name'`. Never derive the name from the class name: minifiers rename classes. A second class with the same `type` throws. 5. In SchemaRecord schemas, use the helpers from `@millwork-ts/warp-drive`: `valueField`, `valueArrayField`, `shapeField` and `shapeArrayField`. They make `kind: 'field'` fields. Never declare a codec or a shape as `kind: 'object'` or `kind: 'schema-object'`: those remove the class prototype and use a nested write path that loses edits. 6. Give the store every Transformation with `transformations: transformations()` from `@millwork-ts/warp-drive`. Call `registerCodecs(codecs)` for each adapter package before `transformations()` runs. Do not register Millwork Transformations one by one. 7. To edit a Polaris record, use `checkout` from `@millwork-ts/warp-drive`, not from `@warp-drive/core`. The Millwork `checkout` lets the copy read its remote values. 8. Change a shape array only with `add`, `remove` and `move`. It is frozen; `push` and `splice` do not work. Do not change the `key` of a member while you edit it. 9. Use `isDirty`, `changes()` and `rollback(path?)` on a shape for dirty state. Do not compare JSON by hand. 10. On a legacy `Model`, a value is `@attr('money', { wire: 'decimal' })`. Core codecs are app transforms already; do not write a transform file. For a codec from another package, call `registerTransforms(owner, { datetime })` from `@millwork-ts/warp-drive/legacy` in an instance initializer. `store.push` does not run `@attr` transforms. 11. A `Model` attribute cannot hold a shape. Put `@value`, `@shape` and `@shapeArray` from `@millwork-ts/warp-drive/legacy` on a plain class, then `withDefaults(modelSchema('order', OrderFields))` with `withDefaults` from `@warp-drive/legacy/model/migration-support`. 12. Ember compiles legacy decorators: write `@field declare city: string`. With standard decorators, write `@field accessor city!: string`. 13. To validate input, use `toStandardSchema(codec, options)` or `toStandardSchema(Address)`. No validation runs when a record reads a field. 14. Never read a date-only string with `new Date('2026-12-01')`. Use a date codec. 15. For a closed list of strings, such as an order status, use real-enums (https://joegaudet.com/real-enums/), not a Millwork codec. ## Example ```ts import { Shape, field } from '@millwork-ts/core' import { checkout, shapeField, valueField } from '@millwork-ts/warp-drive' import { withDefaults } from '@warp-drive/core/reactive' export class Address extends Shape { static override type = 'address' @field declare city: string @field declare zip: string } export const InvoiceSchema = withDefaults({ type: 'invoice', fields: [valueField('total', 'money', { wire: 'decimal' }), shapeField('billTo', Address)], }) const draft = await checkout(invoice) draft.total.toDecimalString() // "5.00" draft.billTo.city = 'Montreal' draft.billTo.isDirty // true draft.billTo.rollback(['city']) ```