chore: add agentic tooling, cleanup

This commit is contained in:
Flo
2026-03-30 12:59:23 +02:00
parent 7645402347
commit ebb42dbad7
40 changed files with 2066 additions and 2 deletions

48
.crosslink/rules/zig.md Normal file
View File

@@ -0,0 +1,48 @@
### Zig Best Practices
#### Code Style
- Follow Zig Style Guide
- Use `const` by default; `var` only when mutation needed
- Prefer slices over pointers when possible
- Use meaningful names; avoid single-letter variables
```zig
// GOOD: Clear, idiomatic Zig
const User = struct {
id: []const u8,
name: []const u8,
};
fn findUser(allocator: std.mem.Allocator, id: []const u8) !?User {
const user = try repository.find(allocator, id);
return user;
}
```
#### Error Handling
- Use error unions (`!T`) for fallible operations
- Handle errors with `try`, `catch`, or explicit checks
- Create meaningful error sets
```zig
// GOOD: Proper error handling
const ConfigError = error{
FileNotFound,
ParseError,
OutOfMemory,
};
fn loadConfig(allocator: std.mem.Allocator) ConfigError!Config {
const file = std.fs.cwd().openFile("config.json", .{}) catch |err| {
return ConfigError.FileNotFound;
};
defer file.close();
// ...
}
```
#### Memory Safety
- Always pair allocations with deallocations
- Use `defer` for cleanup
- Prefer stack allocation when size is known
- Use allocators explicitly; never use global state