How to Regenerate the Web Stylesheet for ai-memory

Set the environment variable TAILWIND_BUILD=1 and run cargo build -p ai-memory-web to regenerate the Tailwind CSS stylesheet at crates/ai-memory-web/static/tailwind.css.

The ai-memory project uses Tailwind CSS to style its web interface. Whenever you modify the Tailwind configuration—such as adding custom colors, utilities, or plugins—you must regenerate the web stylesheet for ai-memory to reflect those changes in the UI. The project provides a built-in environment variable trigger that automates this process during the build phase.

Prerequisites

Before regenerating the stylesheet, ensure you have:

  • Rust toolchain installed (Cargo and rustc)
  • The ai-memory repository cloned locally
  • Node.js available (the build script downloads the Tailwind CLI automatically)

The Regeneration Command

The standard workflow uses a single environment variable to trigger CSS compilation. This approach is documented in both AGENTS.md and CHANGELOG.md for consistency across the codebase.

Basic Regeneration

Run the following command from the repository root:

TAILWIND_BUILD=1 cargo build -p ai-memory-web

This command performs two critical actions:

The -p ai-memory-web flag limits the build to only the web crate, keeping compilation fast and avoiding unnecessary workspace rebuilds.

Release Build Optimization

For production deployments, append the --release flag to generate an optimized binary alongside the regenerated CSS:

TAILWIND_BUILD=1 cargo build --release -p ai-memory-web

How the Build Process Works

In crates/ai-memory-web/build.rs, the build script checks for the TAILWIND_BUILD environment variable. When set to 1, the script invokes the Tailwind CLI before the standard Rust compilation steps, processing the configuration and outputting the generated CSS to static/tailwind.css.

According to the akitaonrails/ai-memory source code, as documented in [AGENTS.md](https://github.com/akitaonrails/ai-memory/blob/main/AGENTS.md#regenerating-the-web-stylesheet) under "Regenerating the web stylesheet", this workflow ensures the stylesheet stays in sync with any Tailwind configuration changes without requiring manual CLI invocations. The same instruction appears in CHANGELOG.md for version-specific visibility.

Key Files and Locations

Understanding the file structure helps when debugging style issues or verifying regeneration:

To verify the file was updated after regeneration, run:

ls -l crates/ai-memory-web/static/tailwind.css

Summary

  • Set TAILWIND_BUILD=1 to trigger Tailwind CSS regeneration during the Cargo build process
  • Use cargo build -p ai-memory-web to target only the web crate for faster iteration
  • The generated stylesheet is written to crates/ai-memory-web/static/tailwind.css
  • Documentation in AGENTS.md and CHANGELOG.md provides the official reference for this workflow
  • The build script handles Tailwind CLI download and invocation automatically

Frequently Asked Questions

Do I need to install Tailwind CSS manually?

No. The build script in crates/ai-memory-web/build.rs handles Tailwind CLI installation automatically when you set TAILWIND_BUILD=1. The tool downloads to the appropriate cache directory without requiring global npm installation.

Why does the stylesheet need manual regeneration?

The ai-memory project commits the generated tailwind.css file to the repository to avoid requiring Node.js for every build. Regeneration is only necessary when the Tailwind configuration—such as tailwind.config.js or input CSS—changes, ensuring the bundled styles reflect new utilities or custom themes.

Can I regenerate the stylesheet without building the Rust code?

The provided workflow couples CSS generation with the Cargo build process. While the build script technically runs before compilation completes, you cannot generate CSS independently without triggering at least a partial build of the ai-memory-web crate.

What happens if I forget to set TAILWIND_BUILD=1?

If you modify the Tailwind configuration but omit the environment variable, the build will use the existing static/tailwind.css file without updating it. Your UI changes will not appear until you rerun the command with TAILWIND_BUILD=1 set.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →