Guidance for AI coding agents working in this repository.
lab is a personal R&D monorepo: learning projects, libraries, experiments,
infrastructure configuration, and dotfiles. The host OS is FreeBSD; Linux-only
tooling runs inside jails.
- Stay inside the project.
- Do not read, create, modify, or delete files outside the repository root.
- This includes user dotfiles, system configuration, and other repositories.
- If a task seems to require it, stop and ask first.
| Path | Contents |
|---|---|
book/ |
Ideas and exercises from books (algos, irex, ostep) |
check/ |
pre-commit check scripts and tools |
dp/ |
Design patterns (errors, graph, proto) |
go/ |
Reusable Go libraries (flags, slices) |
iq/ |
Interview questions, one numbered directory per question |
x/ |
Experimental area: tools, servers, games, wasm, and so on |
infra/ |
Infrastructure configuration and docs (bastion, dns, ldap, ...) |
ansible/ |
Playbooks, roles, and plugins that provision the lab and jails |
ports/ |
FreeBSD ports |
home/ |
Dotfiles and user environment (installed with make) |
nvim/ |
Neovim config and plugins, including the lab-skeleton templates |
third_party/, toolchain/ |
Bazel external deps and toolchain config |
Build systems:
- Go: single module
github.com/skhal/lab(go.modat the root). - C++: Bazel (bzlmod,
MODULE.bazel), C++20, built with-Wall -Wextra -Werror.BUILDfiles are generated by Gazelle. - Python (Poetry), Lua, and shell appear in smaller places.
Each top-level package has its own CI workflow in .github/workflows/, which
runs on changes under that path.
% go build ./...
% go test ./...% bazel run :gazelle # regenerate BUILD files
% bazel test //...
% ./refresh_commands # gazelle + compile_commands.jsonEach Python project has its own pyproject.toml and Poetry environment, such
as ansible/ and poetry/plugin/patch. The root pyproject.toml holds only
the repository-wide Ruff config and the lint group for CI.
make -C home bootstraps the environment of every project with a
pyproject.toml, only when it does not exist yet. Later updates are manual:
run poetry sync in the project after its poetry.lock changes, then
poetry patch in projects with [[tool.poetry-plugin-patch.spec]], such as
ansible/, to re-apply the patches:
% cd ansible
% poetry sync
% poetry patchPython dependencies (ansible-core, pytest) are managed by Poetry from
ansible/pyproject.toml, separate from the root pyproject.toml. Run the
tests from a project or collection folder with a pytest.ini, for example:
% cd ansible/lab
% poetry run pytestOr activate the environment first: eval $(poetry -C ansible env activate).
Ansible collections (requirements.yml in each project, such as
ansible/lab/requirements.yml) are not on PyPI. ansible-galaxy from the
ansible/ environment installs them into the project's .collections
folder. make -C home does it after bootstrapping the environment, or by
hand:
% cd ansible/lab
% poetry run ansible-galaxy collection install \
-r requirements.yml -p .collectionsThe lab.* collections under ansible/collections install the dependencies
from their galaxy.yml into their own .collections folder, see the
collection ansible.cfg. make -C home does it too. Run ansible-lint from
the project or collection folder.
% pre-commit run --files <paths>-
Start from the skeletons. New files are created from templates in
nvim/plugin/lab-skeleton/share/new.*(new.go,new.cc,new.h,new.bzl, ...). Copy their structure rather than inventing a new one. -
License header. Every source file starts with:
Copyright 2026 Samvel Khalatyan. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.Use the file's own comment syntax.
check/cmd/check-licenseenforces it. -
Go
- Every package has a
doc.gowith a package comment. - Every exported entity has a doc comment (enforced by
check-godoc). - Tests live in the external package (
package foo_test) next to the code, use table-driven tests, and compare withgo-cmp. - Format with
goimports. Keep structs field-aligned (fieldalignment). Code must passgo vet,staticcheck, andgo fix. - Do not edit generated
*.pb.gofiles.
- Every package has a
-
C++: Google style (
.clang-format), clean underclang-tidy. Add tests with the code. Run Gazelle after adding or moving files. -
Protobuf: documented messages and fields (
check-pbdoc), and field numbers must be unique (check-nextid). -
Text protos (
*.txtpb): always include theproto-file(schema) andproto-message(message type) comments right after the license header. The message is fully qualified by its proto package. Example frominfra/cmd/certval/config.txtpb:# proto-file: github.com/skhal/lab/infra/cmd/certval/pb/config.proto # proto-message: infra.cmd.certval.Config slack { # webhook is the application webhook from api.slack.com webhook: "https://hooks.slack.com/services/example" }Comment fields to explain their purpose. Format with
txtpbfmt. -
Bazel: format and lint with
buildifier. -
Shell: write scripts in POSIX
sh(1), notbash(1). Use#!/bin/sh, avoid bashisms (arrays,[[ ]], process substitution), and format withshfmt. Shell executables have no file extension. Run project scripts withsh, notbash. -
Markdown, YAML, JSON, TOML, Lua, Python: use the repo formatters (
markdownfmt,yamlfmt,prettier,tombi,stylua,ruff). -
Sorted lists. Respect
keep-sortedblocks. -
No
NOSUBMITmarkers, binary files, or untracked-issueTODOs (checked bycheck-nosubmit,check-todo,check-issue). -
Spelling.
typosruns on all files; see_typos.toml. -
Prefer small, focused changes and add tests with new behavior.
The agent's Bash tool can only run bash or zsh, so it cannot be switched to
sh(1). Stay portable anyway:
- Write every command in POSIX
sh(1)syntax: no arrays,[[ ]],{a,b}brace expansion, process substitution, or$'...'quoting. - Run scripts explicitly with
sh script, neverbash script. - Use
sh -c '...'only when a snippet needsshsemantics; do not wrap ordinary commands in it, because that bypasses the permission rules in.claude/settings.json.
Formatting and linting run through pre-commit (.pre-commit-config.yaml).
Run pre-commit run --files <changed files> before committing and fix what it
reports instead of bypassing hooks.
Short, imperative, prefixed by the area changed, for example
ansible: create pkgbuild jail or roles/jail: update jail config params.
Always show the draft commit message to the user for review before committing. Commit only after they approve it.
- Directory naming: follow style/hier.md when creating, renaming or moving directories.
- Python: follow style/python.md when writing Python code or creating Python projects.