Skip to main content
This guide will walk you through creating a simple Intent Architect module with a working template. You’ll learn the essential concepts and have a functioning module by the end.

What You’ll Build

A module that generates a simple C# class with a constructor and readonly field. This demonstrates:
  • Template creation and registration
  • Code generation using the C# File Builder API
  • Module packaging and installation
This quickstart focuses on getting you productive quickly. For deeper architectural understanding, see the Architecture Overview.

Prerequisites

Before starting, ensure you have:
  • Intent Architect (version 4.6.0 or later)
  • .NET SDK 8.0 or later
  • Visual Studio 2022, VS Code, or Rider

Step-by-Step Guide

1

Create a Module Builder Application

In Intent Architect, create a new application using the Module Builder template.
  1. Open Intent Architect
  2. Click Create New Application
  3. Select Module Builder template
  4. Name it MyFirstModule
  5. Click Create
The Module Builder application type is specifically designed for creating Intent modules. It includes the necessary designers and module building infrastructure.
2

Define Your Template in the Designer

Open the Module Builder designer and create a new C# template:
  1. Right-click on the Templates folder
  2. Select New C# Template
  3. Set the name to SimpleClass
  4. Configure the template:
    • Role: Domain.Entity (or create a custom role)
    • Templating Method: Select C# File Builder
The C# File Builder method is recommended for new templates as it provides a strongly-typed API for generating C# code. Avoid T4 templates for new development.
3

Run the Software Factory

Generate the template scaffolding:
  1. Click the Software Factory Execution button (play icon)
  2. Wait for execution to complete
  3. Open the generated solution in your IDE
The Module Builder will generate a template class at:
Templates/SimpleClass/SimpleClassTemplate.cs
4

Implement the Template Logic

Open SimpleClassTemplate.cs and implement the template:
using System;
using Intent.Engine;
using Intent.Modules.Common.CSharp.Builder;
using Intent.Modules.Common.CSharp.Templates;
using Intent.Modules.Common.Templates;
using Intent.Templates;

[assembly: DefaultIntentManaged(Mode.Fully)]

namespace MyFirstModule.Templates.SimpleClass
{
    [IntentManaged(Mode.Fully, Body = Mode.Merge)]
    public class SimpleClassTemplate : CSharpTemplateBase<object>
    {
        public const string TemplateId = "MyFirstModule.SimpleClass";

        [IntentManaged(Mode.Fully, Body = Mode.Ignore)]
        public SimpleClassTemplate(IOutputTarget outputTarget, object model = null) 
            : base(TemplateId, outputTarget, model)
        {
            // Create a C# file with a class
            CSharpFile = new CSharpFile(this.GetNamespace(), this.GetFolderPath())
                .AddClass($"SimpleClass", @class =>
                {
                    // Add a constructor with a parameter
                    @class.AddConstructor(ctor =>
                    {
                        ctor.AddParameter("string", "name", param =>
                        {
                            // This creates a readonly field and assigns it
                            param.IntroduceReadonlyField();
                        });
                    });
                    
                    // Add a method that uses the field
                    @class.AddMethod("string", "GetGreeting", method =>
                    {
                        method.AddStatement("return $\"Hello, {_name}!\";");
                    });
                });
        }

        [IntentManaged(Mode.Fully)]
        public CSharpFile CSharpFile { get; }

        [IntentManaged(Mode.Fully)]
        protected override CSharpFileConfig DefineFileConfig()
        {
            return CSharpFile.GetConfig();
        }

        [IntentManaged(Mode.Fully)]
        public override string TransformText()
        {
            return CSharpFile.ToString();
        }
    }
}
What’s happening here:
  • CSharpFile - The File Builder API for generating C# code
  • AddClass() - Creates a new class definition
  • AddConstructor() - Adds a constructor
  • IntroduceReadonlyField() - Creates a readonly field and assigns the parameter to it
  • AddMethod() - Adds a method to the class
5

Build and Package the Module

Build your module to create the .imodspec package:
dotnet build
The built module will be in:
bin/Debug/MyFirstModule.imodspec
The .imodspec file is a NuGet package with a different extension. It contains your compiled module DLL and metadata.
6

Install the Module Locally

Install your module for testing:
  1. In Intent Architect, open any application
  2. Right-click on Modules
  3. Select Install Module from File
  4. Browse to your .imodspec file
  5. Click Install
7

Test Your Template

Run the Software Factory to see your template in action:
  1. Click Software Factory Execution
  2. Look for the generated SimpleClass.cs file
  3. Verify the output:
Generated SimpleClass.cs
using System;

namespace YourApplication
{
    public class SimpleClass
    {
        private readonly string _name;

        public SimpleClass(string name)
        {
            _name = name;
        }

        public string GetGreeting()
        {
            return $"Hello, {_name}!";
        }
    }
}

Understanding the Template Structure

Let’s break down the key components:
public const string TemplateId = "MyFirstModule.SimpleClass";
The Template ID must be globally unique across all installed modules. Use a namespace pattern: YourModule.TemplateName.
public SimpleClassTemplate(IOutputTarget outputTarget, object model = null)
  • outputTarget: Determines where the generated file is placed
  • model: Optional metadata model from designers (not used in this example)
CSharpFile = new CSharpFile(this.GetNamespace(), this.GetFolderPath())
The File Builder provides a fluent API for constructing C# code with proper formatting and structure.
public override string TransformText()
{
    return CSharpFile.ToString();
}
This method is called by the Software Factory to get the final output string.

Next Steps

Congratulations! You’ve created your first Intent Architect module. Here’s what to explore next:

Architecture Overview

Understand the module system architecture in depth

Working with Models

Bind templates to designer metadata models

Template Registration

Control when and how templates are instantiated

C# File Builder

Master the C# code generation API

Common Issues

Ensure your template registration is correct and the module is installed. Check the Software Factory logs for errors.
Verify you’re using the correct namespace and type references. Use UseType() for proper type imports.
Check that:
  • The .imodspec file was built successfully
  • The supportedClientVersions in your .imodspec matches your Intent Architect version
  • There are no conflicting module IDs

Need Help?

Visit the Intent Architect support repository to ask questions or report issues

Build docs developers (and LLMs) love