What is the best way to create and use class-type variables in KM?

My terminology may be wrong here- but how can I create and use a class-type variable in KM, with dynamic updating of the instances' objects, and ability for KM to use values from those objects?

So for example if a project in a program has a tag, can that tag be fed into KM and associated aspects of that project (encoded as KM variables) be populated and updated as necessary while working through the project?

Others may differ, but my first reaction would be that

  1. All KM variable are, in the last analysis, strings, and
  2. the best place to achieve the type-level complexities you describe would probably be in KM Execute Script actions (written in JS, AppleScript, or perhaps something else like Python, if you are more familiar with it)

As @ComplexPoint says, KM Variables have only one type: string
They are simple scalar string variables.

However, KM Dictionaries may provide what you need -- I'm not sure as I don't understand enough about your use case.

KM Dictionaries work much like JavaScript objects, but, IMO, they are much harder to use. Depending on what you want to do with the data you have entered, you may be better off using JavaScript for Automation (JXA).

You can either use JXA in standalone script files, or with KM using the Execute a JavaScript For Automation action.

With JXA (as with JavaScript) it is easy to save and restore your data using JSON.

So, if you need more help, please provide us with more details about your use case and workflow. Please read:
Tip: How Do I Get The Best Answer in the Shortest Time?