Skip to main content
skill CX Codex

hare-lang — Claude Code skill: what it does, how to install

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.

MIT 330 installs ★ 298 updated 2026-06-27

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add mohitmishra786/low-level-dev-skills --skill hare-lang -a claude-code
Open on GitHub

What hare-lang 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").

What it helps with

  • 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 for the agent

  • 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

How to install hare-lang

1Skills CLI (Vercel)

npx skills add mohitmishra786/low-level-dev-skills --skill hare-lang -a claude-code

2Manually: put the files in place

~/.claude/skills/hare-lang/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/hare-lang/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about hare-lang

How to install hare-lang in Claude Code?

Run npx skills add mohitmishra786/low-level-dev-skills --skill hare-lang -a claude-code in your terminal. You can also place the instructions directly into ~/.claude/skills/hare-lang/SKILL.md.

What is the primary purpose of the hare-lang skill?

It provides syntax patterns, build instructions, and stdlib modules for writing systems utilities in Hare. It also contrasts Hare with C and Zig to help choose the right tool for auditable codebases.

How does Hare handle C interoperability?

Hare links with C via @extern("c") function signatures and exports Hare routines using the export keyword. External libraries get declared inside hare.mod under the require block.

Source text

SKILL.md · MIT
---
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;
	case => abort();
	};
};

// Slices — pointer + length
fn sum(nums: []i32) i32 = {
	let total = 0i32;
	for (let i = 0z; i < len(nums); i += 1) {
		total += nums[i];
	};
	return total;
};
```

No implicit conversions — explicit casts required.

### 6. C FFI — @extern

```hare
// Link against C library
use c;

@extern("c") fn strlen(s: *const u8) size;

export fn main() void = {
	const s = "hello";
	fmt::println(len(s))!;  // Hare strlen via strings module
};
```

Export Hare to C:

```hare
// Exported C ABI function
export fn my_add(a: i32, b: i32) i32 = {
	return a + b;
};
```

```bash
hare build -o libmytool.a
# Link from C with generated headers or manual declarations
```

```hare
// cgo-style module linking in hare.mod
module mytool
require (
    libc
)
```

### 7. Testing

```hare
@test fn test_add() void = {
	assert(sum(&[1i32, 2, 3]) == 6);
};

@test fn test_error() void = {
	match (read_file("/nonexistent")) {
	case => abort("expected error");
	case let err: os::error => void;
	};
};
```

```bash
hare test -v
```

### 8. Hare vs C vs Zig

| Aspect | Hare | C | Zig |
|--------|------|---|-----|
| Memory safety | Some (no null, tagged errors) | Manual | Manual + optional safety |
| Compile time | Fast | Fast | Comptime heavy |
| Stdlib | Minimal, stable | libc | Extensive |
| C interop | `@extern` | Native | `@cImport` |
| Generics | No (comptime limited) | No | Comptime generics |
| Best for | Utilities, tools | Everything | Systems with metaprogramming |

### 9. Use cases

```
Good Hare fits
├── CLI utilities (grep-like, init tools)
├── Build tools and scripts replacing shell
├── Network daemons with simple protocol
└── Auditable security-sensitive code

Consider C/Zig instead when
├── Heavy generic metaprogramming needed (Zig)
├── Existing massive C ecosystem glue
└── GPU/kernel domains with immature Hare support
```

## Common Problems

| Symptom | Cause | Fix |
|---------|-------|-----|
| `unknown type` | Missing import | Add `use module;` |
| FFI link error | Library not in hare.mod | Add require; correct `-l` flags |
| Error not handled | Missing `?` or match | Propagate or handle all cases |
| UTF-8 error | Invalid bytes in string | Validate with `strings::fromutf8` |
| Test not found | Missing `@test` | Name fn with `@test` attribute |
| Platform syscall missing | Hare stdlib gap | Use `@extern` to libc |

## Related Skills

- `skills/zig/zig-compiler` — Zig as alternative systems language
- `skills/zig/zig-cinterop` — Zig C interop comparison
- `skills/compilers/gcc` — C toolchain alongside Hare
- `skills/languages/carbon-lang` — other emerging systems languages
- `skills/build-systems/make` — integrating Hare into Makefiles
- `skills/runtime-safety/sanitizers` — C interop safety testing

© mohitmishra786 · MIT · mohitmishra786/low-level-dev-skills

Similar skills

All skills for Programming languages →

From the same set140

The whole set →
af-xdp Configures AF_XDP sockets and shared UMEM buffers for low-latency packet processing. Helps implement fast network filtering directly in userspace. CX Codex +1 359installs triton-lang triton-lang is a Claude Code skill that teaches agents to write Triton GPU kernels with @triton.jit, masked block operations, atomics, autotuning, and PyTorch integration. CX Codex +1 358installs containers-internals containers-internals is a Claude Code skill for Linux container internals, activated for queries about namespaces, runc, seccomp, and escape vulnerabilities. CX Codex +1 358installs rdma-verbs rdma-verbs guides coding agents through RDMA programming using libibverbs for InfiniBand and RoCE fabrics. Useful when setting up queue pairs or perftest benchmarks. CX Codex +1 356installs riscv-privileged The riscv-privileged skill supports RISC-V kernel and firmware development, covering privileged modes, CSRs, traps, interrupt controllers, OpenSBI, page tables, and QEMU testing. CX Codex +1 355installs mpi Guides agents through distributed-memory programming with MPI, collective communications, hybrid OpenMP patterns, and mpirun execution. CX Codex +1 354installs verilog-basics-for-lowlevel verilog-basics-for-lowlevel — a skill that teaches firmware and kernel engineers to read Verilog RTL: modules, clocking, reset logic, bus protocols. Use it when docs are unclear and hardware behavior explains driver bugs. CX Codex +1 345installs carbon-lang carbon-lang is a Claude Code skill for exploring Carbon syntax, C++ interoperability, and toolchain builds. It supports migration prototyping and language assessment. CX Codex +1 329installs

Project sponsors

Companies that keep this analytics open