YANG — 18 Operations for AI Agents

YANG models the configuration of the network itself — NETCONF, RESTCONF, vendor device trees. act101 navigates modules, containers, and leaves structurally, so agents work with device models instead of scrolling schema files.

This page is the canonical reference an AI coding agent uses to refactor, query, and analyze YANG code through the act MCP server. 18 operations available: 0 refactor, 18 query, 0 analysis. Each operation is callable from Claude Code, Cursor, Codex, OpenCode, or any MCP-compatible agent host. Click any operation for a stable anchor link suitable for citation.

18Query

Worked YANG examples

act101 reads a YANG module's data-definition statements (container, list, leaf, leaf-list, choice), schema-shaping statements (grouping, typedef, identity, feature, extension), and RPC/action/notification operations as declarations. skeleton tags a data node variable, an RPC/action/notification function, and the module itself module. symbols covers the same set and reaches one level deeper into an enumeration's own labeled members, whose captured name keeps the surrounding quote marks from the underlying string literal. The unit of structure in this grammar is the schema node: both queries recurse through nested containers, lists, and leaves, since YANG's own data tree is itself nested. Each example below is the verbatim output of the command shown, run against the file shown. Query outputs are pretty-printed with the timing block omitted.

Read the VLAN module's data tree and RPC as a skeleton

acme-vlan.yang models per-VLAN network configuration: a vlans container holding a keyed vlan list with id/name/admin-status leaves, and a create-vlan RPC that provisions a new entry.

$ act query skeleton acme-vlan.yang

Before

module acme-vlan {
  namespace "urn:acme:vlan";
  prefix "vlan";

  container vlans {
    list vlan {
      key "id";

      leaf id {
        type uint16;
      }

      leaf name {
        type string;
      }

      leaf admin-status {
        type enumeration {
          enum "up";
          enum "down";
        }
      }
    }
  }

  rpc create-vlan {
    input {
      leaf id {
        type uint16;
      }
    }
  }
}

Output

{
    "type": "Skeleton",
    "declarations": [
        {
            "kind": "module",
            "name": "acme-vlan",
            "range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 1,
                    "column": 1,
                    "byte_offset": 0
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 33,
                    "column": 2,
                    "byte_offset": 427
                }
            },
            "name_range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 1,
                    "column": 8,
                    "byte_offset": 7
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 1,
                    "column": 17,
                    "byte_offset": 16
                }
            }
        },
        {
            "kind": "variable",
            "name": "vlans",
            "range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 5,
                    "column": 3,
                    "byte_offset": 68
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 24,
                    "column": 4,
                    "byte_offset": 337
                }
            },
            "name_range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 5,
                    "column": 13,
                    "byte_offset": 78
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 5,
                    "column": 18,
                    "byte_offset": 83
                }
            }
        },
        {
            "kind": "variable",
            "name": "vlan",
            "range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 6,
                    "column": 5,
                    "byte_offset": 90
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 23,
                    "column": 6,
                    "byte_offset": 333
                }
            },
            "name_range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 6,
                    "column": 10,
                    "byte_offset": 95
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 6,
                    "column": 14,
                    "byte_offset": 99
                }
            }
        },
        {
            "kind": "variable",
            "name": "id",
            "range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 9,
                    "column": 7,
                    "byte_offset": 125
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 11,
                    "column": 8,
                    "byte_offset": 163
                }
            },
            "name_range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 9,
                    "column": 12,
                    "byte_offset": 130
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 9,
                    "column": 14,
                    "byte_offset": 132
                }
            }
        },
        {
            "kind": "variable",
            "name": "name",
            "range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 13,
                    "column": 7,
                    "byte_offset": 171
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 15,
                    "column": 8,
                    "byte_offset": 211
                }
            },
            "name_range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 13,
                    "column": 12,
                    "byte_offset": 176
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 13,
                    "column": 16,
                    "byte_offset": 180
                }
            }
        },
        {
            "kind": "variable",
            "name": "admin-status",
            "range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 17,
                    "column": 7,
                    "byte_offset": 219
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 22,
                    "column": 8,
                    "byte_offset": 327
                }
            },
            "name_range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 17,
                    "column": 12,
                    "byte_offset": 224
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 17,
                    "column": 24,
                    "byte_offset": 236
                }
            }
        },
        {
            "kind": "function",
            "name": "create-vlan",
            "range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 26,
                    "column": 3,
                    "byte_offset": 341
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 33,
                    "column": 1,
                    "byte_offset": 426
                }
            },
            "name_range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 26,
                    "column": 7,
                    "byte_offset": 345
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 26,
                    "column": 18,
                    "byte_offset": 356
                }
            }
        },
        {
            "kind": "variable",
            "name": "id",
            "range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 28,
                    "column": 7,
                    "byte_offset": 377
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 30,
                    "column": 8,
                    "byte_offset": 415
                }
            },
            "name_range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 28,
                    "column": 12,
                    "byte_offset": 382
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 28,
                    "column": 14,
                    "byte_offset": 384
                }
            }
        }
    ]
}

The skeleton reports eight declarations, nested through the data tree: acme-vlan as module, vlans/vlan/id/name/admin-status all as variable, create-vlan as function, and the RPC's own input leaf id as a second, distinct variable declaration.

List every leaf and the enumeration's labeled members as symbols

admin-status is typed as an enumeration with two labeled values, up and down.

$ act query symbols acme-vlan.yang

Before

module acme-vlan {
  namespace "urn:acme:vlan";
  prefix "vlan";

  container vlans {
    list vlan {
      key "id";

      leaf id {
        type uint16;
      }

      leaf name {
        type string;
      }

      leaf admin-status {
        type enumeration {
          enum "up";
          enum "down";
        }
      }
    }
  }

  rpc create-vlan {
    input {
      leaf id {
        type uint16;
      }
    }
  }
}

Output

{
    "type": "Symbols",
    "symbols": [
        {
            "name": "acme-vlan",
            "kind": "module",
            "range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 1,
                    "column": 8,
                    "byte_offset": 7
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 1,
                    "column": 17,
                    "byte_offset": 16
                }
            },
            "visibility": "unknown"
        },
        {
            "name": "vlans",
            "kind": "variable",
            "range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 5,
                    "column": 13,
                    "byte_offset": 78
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 5,
                    "column": 18,
                    "byte_offset": 83
                }
            },
            "visibility": "unknown"
        },
        {
            "name": "vlan",
            "kind": "variable",
            "range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 6,
                    "column": 10,
                    "byte_offset": 95
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 6,
                    "column": 14,
                    "byte_offset": 99
                }
            },
            "visibility": "unknown"
        },
        {
            "name": "id",
            "kind": "variable",
            "range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 9,
                    "column": 12,
                    "byte_offset": 130
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 9,
                    "column": 14,
                    "byte_offset": 132
                }
            },
            "visibility": "unknown"
        },
        {
            "name": "name",
            "kind": "variable",
            "range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 13,
                    "column": 12,
                    "byte_offset": 176
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 13,
                    "column": 16,
                    "byte_offset": 180
                }
            },
            "visibility": "unknown"
        },
        {
            "name": "admin-status",
            "kind": "variable",
            "range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 17,
                    "column": 12,
                    "byte_offset": 224
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 17,
                    "column": 24,
                    "byte_offset": 236
                }
            },
            "visibility": "unknown"
        },
        {
            "name": "\"up\"",
            "kind": "variable",
            "range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 19,
                    "column": 16,
                    "byte_offset": 281
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 19,
                    "column": 20,
                    "byte_offset": 285
                }
            },
            "visibility": "unknown"
        },
        {
            "name": "\"down\"",
            "kind": "variable",
            "range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 20,
                    "column": 16,
                    "byte_offset": 302
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 20,
                    "column": 22,
                    "byte_offset": 308
                }
            },
            "visibility": "unknown"
        },
        {
            "name": "create-vlan",
            "kind": "function",
            "range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 26,
                    "column": 7,
                    "byte_offset": 345
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 26,
                    "column": 18,
                    "byte_offset": 356
                }
            },
            "visibility": "unknown"
        },
        {
            "name": "id",
            "kind": "variable",
            "range": {
                "start": {
                    "file": "acme-vlan.yang",
                    "line": 28,
                    "column": 12,
                    "byte_offset": 382
                },
                "end": {
                    "file": "acme-vlan.yang",
                    "line": 28,
                    "column": 14,
                    "byte_offset": 384
                }
            },
            "visibility": "unknown"
        }
    ]
}

symbols adds the two enum members, for ten entries total, but keeps their surrounding quote marks in the reported name — "up" and "down", not up and down — since the rule captures the enum's quoted string argument node directly.

Query

18 query tools, the same on every supported language. Descriptions live in the shared reference: /docs/query-tools.

callers control_flow data_flow definition diagnostics effect_closure effect_summary fix_auto get_type graph import_organize interface mutations references repo_outline skeleton symbols symbols_batch

← YAMLZig →