Skip to content

Getting started

This guide will help you install the Gram ecosystem and compile your first recipe.

  1. Installation

    Install the gram CLI globally with your package manager of choice — it runs on both Node.js (>=20) and Bun:

    npm install -D @gram-lang/cli
  2. Editor Setup

    Because Gram treats recipes as code, having the right editor makes a huge difference.

    Search for “Gram - Recipe Language” in the Extensions view (Ctrl+Shift+X / Cmd+Shift+X) and install it, or grab it directly from the VS Code Marketplace.

    Building from source instead
    git clone https://git.gram-lang.org/gram-lang/gram.git
    cd gram
    bun install
    
    # Build the extension package (this generates a .vsix file)
    cd packages/vscode-extension
    bun run package
    
    # Install the package in VS Code
    code --install-extension gram-lang-*.vsix
  3. Initializing a Project

    Before writing any recipe, it’s highly recommended to initialize a Gram workspace. Run this command in a new folder:

    gram init

    This command scaffolds a .gram/ directory with a configuration file and a starter database.

  4. Writing a Simple Recipe

    Let’s make some pancakes, shall we?

    Create a new file named pancakes.gram, open it in the editor, and add the following basic recipe:

    ---
    title: Pancakes
    portions: 2
    ---
    
    ## Batter ->&batter
    
    In a #medium bowl{}, mix the @flour{160g}, @baking powder{1 tsp}, @sugar{1 tbsp} and @salt{1/4 tsp}. ->&dry mix{}
    
    To the &dry mix{}, add the @buttermilk{1 cup}, @egg{1} and the @vanilla extract{1/2 tsp}.
    
    ## Cooking
    
    Pour the &batter on a #griddle on ^{medium heat} and cook for ~{2min}.
  5. Compiling the Recipe

    Time to see the compiler in action!

    Run the following command in the terminal to compile the recipe into a structured JSON format:

    gram build pancakes.gram

    This command will parse the recipe and output its structured JSON representation. By default, it prints to the console, but you can save it to a file:

    gram build pancakes.gram -o pancakes.json

    While the JSON output is incredibly useful for building applications around Gram, it is not the most readable format for humans!

    To see your recipe rendered directly in your terminal, you can use the view command:

    gram view pancakes.gram

Now that you have seen the basics, it’s time to discover the true power of Gram’s relational variables, timers, and automatic math scaling by writing a more complex recipe: