# Analytixus Repository & DnAML

## Purpose
This skill teaches you how to work with the Analytixus repository and DnAML — the metadata
language used to define data model objects. Use it whenever you interact with the repository:
reading existing structures, designing new artifacts, or implementing changes.

## DnAML Reference — Always First

Before writing any DnAML content, call `get_dnaml_reference`.
The reference contains the current, authoritative syntax. Never guess or invent DnAML syntax.

## Repository Structure

Objects are organized in a three-level hierarchy:

```
Solution
└── Folder        (e.g., "Gold")
    └── Source    (e.g., "Gold")
        └── Node  (e.g., "Store_DimCustomer")
```

Object names are addressed as `Folder.Schema.ObjectName`:
- `Gold.Gold.Store_DimCustomer`
- `Silver.Silver.Store_WWI_Sales_Customers_Key`
- `Silver.Silver.Access_WWI_Sales_Customers_Actual`

## Tools

### Exploration
- `repository_get_tree` — full solution tree. Call this first to understand what exists.
- `repository_read_node(nodeId)` — DnAML content of one node.
- `repository_read_node_recursive(nodeId)` — a node and all its children.

### Writing
- `repository_write_node(nodeId, content)` — write DnAML to an existing node.
- `repository_add_node_under_source(sourceId, name, content)` — create a new node.
- `repository_add_node_under_folder(folderId, name, content)` — create under a folder.
- `repository_add_source(folderId, name)` — create a new source under a folder.
- `repository_add_folder(name)` — create a new top-level folder.

### Deleting (confirm with user first)
- `repository_delete_node(nodeId)`
- `repository_delete_source_recursive(sourceId)`
- `repository_delete_folder_recursive(folderId)`

## Read-Before-Write Rule

For every node you plan to write:
1. Call `repository_read_node` to check the current state.
2. Understand what exists before deciding what to change.
3. Write only what the task requires — preserve everything else.
4. Verify: read the node once after writing to confirm the result.

## Startup Protocol for DnAML Work

1. `get_dnaml_reference` — learn the current syntax
2. `repository_get_tree` — understand the existing structure
3. Read relevant existing nodes with `repository_read_node`
4. Then design or implement

## Anti-Patterns
- **Guessing DnAML syntax**: Always call `get_dnaml_reference` first.
- **Writing without reading**: Never overwrite a node without knowing its current state.
- **Creating duplicates**: Always check `repository_get_tree` before creating folders or sources.
- **Scope creep**: Only touch nodes that are within the task scope.
