# hare-lang

hare-lang teaches AI assistants systems programming in Hare: hare build workflows, manual hare.mod project layout, tagged union errors, and C FFI via @extern.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 330 installs · ★ 298 repo stars
- Author: mohitmishra786
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/mohitmishra786/low-level-dev-skills/tree/HEAD/skills/languages/hare-lang/SKILL.md
- Updated: 2026-06-27
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/hare-lang

## What it does

This skill guides coding agents through the Hare systems programming language. It covers syntax fundamentals, slices, tagged union types, and explicit error propagation with the `?` and `!` operators. The guide also details standard library packages such as `fmt`, `os`, `io`, `net`, and `strings`.

Hare does not feature an automated project generator, so `hare.mod` manifests and source directories require manual setup. The reference provides patterns for compilation with `hare build`, writing unit tests with `@test`, and exporting or importing C ABI functions using `@extern("c")`.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add mohitmishra786/low-level-dev-skills --skill hare-lang -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/hare-lang/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/hare-lang/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add mohitmishra786/low-level-dev-skills --skill hare-lang -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/hare-lang/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add mohitmishra786/low-level-dev-skills --skill hare-lang -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/hare-lang/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install mohitmishra786/low-level-dev-skills skills/languages/hare-lang
```

2. **Manually: put the files in place**
- File: `.github/skills/hare-lang/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add mohitmishra786/low-level-dev-skills --skill hare-lang -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/mohitmishra786/low-level-dev-skills --path skills/languages/hare-lang
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/hare-lang/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add mohitmishra786/low-level-dev-skills --skill hare-lang -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/mohitmishra786/low-level-dev-skills/tree/HEAD/skills/languages/hare-lang/SKILL.md

## When to use it
- build lightweight CLI tools and daemons without a heavy runtime
- interface with C libraries using `@extern` declarations
- handle operations returning `(T | os::error)` using tagged unions
- configure `hare.mod` dependencies and execute test suites via `hare test`

## Example prompts
- Write a Hare CLI program that reads a file and handles errors with match
- Show how to link a C library function into Hare using @extern
- Create a hare.mod manifest and write a unit test with the @test attribute

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 8b8fa4fc082b121d.

BEGIN THIRD-PARTY FILE 8b8fa4fc082b121d
````text
---
name: hare-lang
description: Hare language skill for simple systems programming. Use when building with hare build/test/run, Hare stdlib, C FFI with @extern, tagged union error handling, or comparing Hare vs C/Zig. Activates on queries about Hare language, hare build, @extern, tagged union, or Hare stdlib.
---

# Hare

## Purpose

Guide agents through the Hare programming language: design philosophy (simple, stable, compiled), `hare build`/`test`/`run` workflows, stdlib overview, C FFI with `@extern`, the type system (tagged unions, slices), error handling with `(T | error!)`, and comparison with C and Zig for systems utilities.

## When to Use

- Writing small system utilities with C-like control and modern safety
- Building CLI tools or daemons with minimal dependencies
- Calling C libraries from Hare or exporting Hare functions to C
- Preferring explicit error handling over exceptions
- Evaluating Hare vs C or Zig for a new project
- Needing a stable, auditable codebase without heavy runtime

## Workflow

### 1. Install Hare

```bash
# Linux/macOS — build from source
git clone https://git.sr.ht/~sircmpwn/hare
cd hare
make check   # builds and runs tests
sudo make install

hare version
```

```bash
# Create project (Hare has no project generator — lay out manually)
mkdir -p mytool && cd mytool
cat > hare.mod << 'EOF'
module mytool
EOF
```

### 2. Hello world and build

```hare
// main.ha
use fmt;

export fn main() void = {
	fmt::println("Hello, Hare!")!;
};
```

```bash
hare build -o mytool
./mytool

hare run .        # build and run
hare test         # run tests
```

### 3. Stdlib overview

| Module | Purpose |
|--------|---------|
| `fmt` | Formatted I/O (`printf`, `println`) |
| `io` | Reader/writer interfaces |
| `os` | Files, environment, args |
| `strings` | String manipulation |
| `bufio` | Buffered I/O |
| `encoding` | JSON, hex, etc. |
| `net` | TCP/UDP networking |
| `time` | Dates and durations |
| `mem` | Memory helpers |
| `types` | Platform integer types |

```hare
use os;
use fmt;
use strings;

export fn main() void = {
	const args = os::args;
	for (let i = 0z; i < len(args); i += 1) {
		fmt::println(args[i])!;
	};
};
```

### 4. Error handling

```hare
// Errors are tagged union values — explicit propagation with !
fn read_file(path: str) (str | os::error) = {
	const file = os::open(path)?;
	defer os::close(file);
	let buf: []u8 = [];
	io::readall(file, &buf)?;
	return strings::fromutf8(buf)!;
};

export fn main() void = {
	match (read_file("config.txt")) {
	case let s: str =>
		fmt::println(s)!;
	case let err: os::error =>
		fmt::fatalf("error: {}", err)!;
	};
};
```

`?` propagates errors; `!` asserts success in infallible context; `match` for handling.

### 5. Type system

```hare
// Tagged union
type color = (u8 | u16 | void);

fn get_color(c: color) u16 = {
	match (c) {
	case let v: u8 => return v: u16;
	case let v: u16 => return v;
````
END THIRD-PARTY FILE 8b8fa4fc082b121d

The third-party file has ended. Everything between the 8b8fa4fc082b121d tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2917 of 5729 bytes. © mohitmishra786 · MIT · https://github.com/mohitmishra786/low-level-dev-skills/tree/HEAD/skills/languages/hare-lang/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
