with one click
typedown-expert
// Expert guidance on writing correct Typedown code, focusing on syntax, best practices, and common pitfalls.
// Expert guidance on writing correct Typedown code, focusing on syntax, best practices, and common pitfalls.
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | typedown-expert |
| description | Expert guidance on writing correct Typedown code, focusing on syntax, best practices, and common pitfalls. |
This skill provides expert knowledge for writing Typedown files (.td). Typedown is a Consensus Modeling Language that embeds Pydantic models and Pytest logic into Markdown.
File Structure:
.td file MUST start with a Level 1 Heading (# Title) and a brief textual description. Never start with a code block.Model Blocks (model:<Name>):
model:ClassName block.typing or pydantic inside the block unless it's a specific, non-standard import. The environment pre-loads standard types.class User inside ```model:User).Config Blocks (config):
config.td files only. Do NOT use config blocks in regular .td files.config are automatically exposed to the directory scope and inherited by subdirectories.Entity Blocks & Identifiers:
entity <Type>: <ID>alice) or a slug (user-alice-v1).[[ID]] (Wiki Link) syntax.[[...]]):[[id]]
[[alice]], [[users/alice]][[sha256:...]]
former):When tracking object changes over time:
former: [[<Identifier>]][[]] for the former field.former pointers to ensure historical stability. Globally unique IDs are also acceptable.spec):@target.Typedown is not just a syntax; it is a rigorous method for converting loose natural language into strict systemic consensus. When using Typedown, follow this 5-step cognitive process:
Scan the unstructured text or requirement to identify Key Entities. Immediately instantiate them using entity blocks to fix their existence.
entity:<Type> blocks with YAML content.Analyze the entity blocks you just created. Abstract their common structure into Pydantic models (model).
model:<Type> blocks.config.td or common.td and export them if they are used across multiple files.Analyze the business rules governing these entities. Enforce them using three layers of defense:
EmailStr, PositiveInt).@field_validator or @model_validator for self-contained consistency.spec blocks with @target tags for cross-entity or graph-level validation (e.g., "A specific user must exist in the admin group").If you are unsure about advanced syntax (e.g., how to use former for versioning or tags for filtering):
_reference directory (it is git-ignored).git clone https://github.com/IndenScale/typedown.git _reference/typedown.docs/ or cookbook/01_getting_started/ in the reference to ground your knowledge.Never assume your code is correct. Always verify with the compiler.
uvx typedown check <path> immediately after editing.Step 1: Raw Draft "We need a server 'Alpha' compliant with ISO-27001."
Step 2: Typedown Modeling
class ComplianceStandard(str, Enum):
ISO_27001 = "ISO-27001"
SOC2 = "SOC2"
class Server(BaseModel):
hostname: str
compliance: List[ComplianceStandard]
@model_validator(mode='after')
def check_security(self):
if ComplianceStandard.ISO_27001 in self.compliance:
# Enforce some logic...
pass
return self
hostname: "alpha-01"
compliance:
- "ISO-27001"