# Standard Library Examples

> This chapter explores Tactus's built-in standard library - utilities and primitives that make it easier to build robust AI workflows.

Canonical: https://tactus.anth.us/examples/standard-library/

::band{columns="document-hero wide"}

[Examples](/examples/) / Standard Library

# Standard Library

This chapter explores Tactus's built-in standard library - utilities and primitives that make it easier to build robust AI workflows.

::band{tone="muted"}

## Examples in This Chapter

### [State Management](/examples/standard-library/state-management/)

Demonstrates state operations in Tactus workflows. This example shows:
- Initializing state with metatable syntax (`state.key = value`)
- Using `State.increment()` for atomic counter operations
- Reading state values for output and validation
- Tracking workflow progress with state variables
- State assertions in specifications

*Has Specs*

### [File Io](/examples/standard-library/file-io/)

Comprehensive demonstration of file I/O operations across different formats. This example shows:
- Reading CSV files with automatic header handling
- Processing data with Lua table operations
- Writing results to multiple formats (CSV, JSON, text)
- Using `require()` to import I/O libraries (`tactus.io.csv`, `tactus.io.json`, `tactus.io.file`)
- Relative file paths from procedure directory
- Working with the gitignored `output/` folder

*Has Specs*

### [Message History](/examples/standard-library/message-history/)

Shows how to manage conversation history with the MessageHistory primitive. This example demonstrates:
- Manually injecting system messages with `MessageHistory.inject_system()`
- Appending user messages with `MessageHistory.append()`
- Retrieving full conversation history with `MessageHistory.get()`
- Iterating through messages with `python.iter()`
- Tracking conversation length and message roles
- Clearing history when needed with `MessageHistory.clear()`

*Has Specs · Requires API Keys*

::band{columns="neighbors"}

- [*← Previous Chapter* **Human-in-the-Loop (HITL)**](/examples/human-in-the-loop/)
- [*Next Chapter →* **Specifications**](/examples/specifications/)

::band{columns="cta"}

## Want to contribute?

The examples repository is open source. Add your own examples or improve existing ones.

::button{href="https://github.com/AnthusAI/Tactus-examples" label="View on GitHub" size="lg"}
