**Organization: spec → rule**
Default: one file, one implicit repo. No `repo` blocks unless multi-namespace workspace requested. Structure: **spec → rule**.
**Spec** = namespace for `data` and `rules`. **Rule** = named computed value. Reference rules by name; engine resolves if name is data or rule. One file can have multiple specs.
Hierarchical names: `spec employee/contract`. Effective date for temporal changes: `spec pricing 2026-01-01`.
Sole documentation: commentary `"""..."""` immediately after `spec <name> [<effective>]` (before `uses`, `data`, or `rule`).
**Example A — minimal single-spec file**
```lemma
spec pricing 2026-01-01
"""
Pricing rules for bulk and member discounts.
Commentary must follow the spec line; it cannot go anywhere else.
"""
data qty: number
data base_price: 100
data is_member: false
rule vat_amount: base_price * 21%
rule price_with_vat: base_price + vat_amount
rule bulk_discount:
qty >= 100 and price_with_vat > 500
rule discount: 0%
unless qty >= 10 then 10%
unless bulk_discount then 15%
unless is_member then 20%
rule discount_amount: base_price * discount
rule price_with_discount: base_price - discount_amount
```
**Example B — multi-spec composition (same file)**
```lemma
spec base_config
data standard_discount: 5%
data tax_rate: 21%
data base_price: number -> minimum 0 -> suggest 100
rule tax_amount: base_price * tax_rate
rule price_with_tax: base_price + tax_amount
rule discount_amount: base_price * standard_discount
rule discounted_price: base_price - discount_amount
rule final_price: discounted_price * (100% + tax_rate)
spec line_item
data qty: number -> minimum 0 -> suggest 10
uses pricing: base_config
rule line_total: pricing.final_price * qty
rule has_discount: pricing.standard_discount > 0%
spec simple_order
uses line: line_item
with line.qty: 100
rule order_total: line.line_total
rule effective_unit_price: order_total / line.qty
```
- `uses alias: target_spec`: imports spec in same file.
- Reference members: `alias.field` or `alias.rule_name`.
- `with alias.field: value`: sets imported data. Do not use `data alias.field`. Local `with name: …` invalid — use `data name: …`.
**LemmaBase — shared specs from the registry**
Specs on [LemmaBase.com](https://lemmabase.com) imported with `@` repo qualifiers. Search: [lemmabase.com/search?q=](https://lemmabase.com/search?q=) (e.g. `?q=finance`).
```lemma
spec invoicing
"""
Invoice lines using ISO country codes from LemmaBase.
"""
uses lemma units
uses iso: @iso/countries alpha2 2026-01-01
data price: measure
-> unit eur 1
data country: iso.code
rule tariff: 0 eur
unless country is "NL" then price * 5%
rule total: price + tariff
```
Forms:
- `uses @user/repo spec_name`: import registry spec (alias = spec name)
- `uses alias: @user/repo spec_name`: import with alias (`iso.field`)
- `uses @user/repo spec_name 2026-01-01`: pin effective date
Reference imported members: `iso.code`. Detail: [Registry](https://github.com/lemma/lemma/blob/main/cli/documentation/reference/registry.md).
`repo` blocks namespace specs across contexts (e.g., `repo accounting`). Skip unless asked. Details: [Composing specs](https://github.com/lemma/lemma/blob/main/cli/documentation/learn/composing_specs.md).