# How to Regenerate the Web Stylesheet for ai-memory

> Learn how to regenerate the web stylesheet for ai-memory. Set TAILWIND_BUILD=1 and run cargo build to update the Tailwind CSS file. Follow these simple steps for efficient development.

- Repository: [Fabio Akita/ai-memory](https://github.com/akitaonrails/ai-memory)
- Tags: how-to-guide
- Published: 2026-09-11

---

**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`](https://github.com/akitaonrails/ai-memory/blob/main/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`](https://github.com/akitaonrails/ai-memory/blob/main/AGENTS.md) and [`CHANGELOG.md`](https://github.com/akitaonrails/ai-memory/blob/main/CHANGELOG.md) for consistency across the codebase.

### Basic Regeneration

Run the following command from the repository root:

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

```

This command performs two critical actions:

- Downloads the Tailwind CLI automatically if not present
- Overwrites [`crates/ai-memory-web/static/tailwind.css`](https://github.com/akitaonrails/ai-memory/blob/main/crates/ai-memory-web/static/tailwind.css) with a fresh, production-ready stylesheet

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:

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

```

## How the Build Process Works

In [`crates/ai-memory-web/build.rs`](https://github.com/akitaonrails/ai-memory/blob/main/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`](https://github.com/akitaonrails/ai-memory/blob/main/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)](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`](https://github.com/akitaonrails/ai-memory/blob/main/CHANGELOG.md) for version-specific visibility.

## Key Files and Locations

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

- [`crates/ai-memory-web/static/tailwind.css`](https://github.com/akitaonrails/ai-memory/blob/main/crates/ai-memory-web/static/tailwind.css) — The generated stylesheet consumed by the web UI
- [`AGENTS.md`](https://github.com/akitaonrails/ai-memory/blob/main/AGENTS.md) — Contains the canonical regeneration command under the "Regenerating the web stylesheet" section
- [`CHANGELOG.md`](https://github.com/akitaonrails/ai-memory/blob/main/CHANGELOG.md) — Reiterates the command for version-specific release notes
- [`docs/ARCHITECTURE.md`](https://github.com/akitaonrails/ai-memory/blob/main/docs/ARCHITECTURE.md) — Describes the web crate layout and Tailwind integration architecture

To verify the file was updated after regeneration, run:

```bash
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`](https://github.com/akitaonrails/ai-memory/blob/main/crates/ai-memory-web/static/tailwind.css)
- Documentation in [`AGENTS.md`](https://github.com/akitaonrails/ai-memory/blob/main/AGENTS.md) and [`CHANGELOG.md`](https://github.com/akitaonrails/ai-memory/blob/main/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`](https://github.com/akitaonrails/ai-memory/blob/main/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`](https://github.com/akitaonrails/ai-memory/blob/main/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`](https://github.com/akitaonrails/ai-memory/blob/main/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`](https://github.com/akitaonrails/ai-memory/blob/main/static/tailwind.css) file without updating it. Your UI changes will not appear until you rerun the command with `TAILWIND_BUILD=1` set.