Imported from Igormm/bs (
AGENTS.md). Install upstream withnpx skills add Igormm/bs. Copyright stays with the author.
AI Agent Guide — BS Framework
Instructions for AI assistants, coding agents, and LLM-based tools working with the BS Bash framework.
What is BS?
BS is a modular Bash 4+ framework and standard library. It provides:
bs— shebang interpreter and CLI (#!/usr/bin/env bs)bootstrap/loader.sh— module loader with dependency resolution (load "lib/io/streams")bootstrap/bs.sh— pre-kernel root namespace: dependency-free helpers available before the loader (shell detectionbs::shell::*,bs::script_dir, PATH tweak); sourced by entry points,bootstrap/init.shand the loader itselfcore/— framework kernel:args,logger,errorhandler,const,utils,version,config,deps,prereq,langlib/— standard library:io/streams,io/files,io/process,system/*,integration/*,ui/*, etc.tests/— custom test framework, ShellCheck validation, syntax validation
All modules are Bash 4+ scripts. No external dependencies are required at runtime.
How AI should work with this framework
- Always use the
bsinterpreter orbootstrap/init.sh. Do not source modules directly in new scripts. - Follow the code style guide:
documentation/en/code-style-guide.md/documentation/ru/code-style-guide.md. - Run validators after any change:
bash tests/validatesyntax.sh bash tests/validateshellcheck.sh bash tests/runalltests.sh - Add tests for new public functions or behaviors.
- Keep changes minimal. Prefer small, focused commits.
- Do not mutate git history (no
git rebase,git reset,git push --force) unless explicitly asked.
Module skeleton
#!/usr/bin/env bs
# shellcheck shell=bash
# lib/group/module.sh — one-line description
# @depends core/const, core/logger, core/utils
# Source Guard
bs::guard "MODULE_NAME" || return 0
# Dependencies
bs::source_relative "../../core/const.sh" "../../core/logger.sh" "../../core/utils.sh"
# Public API
group::module::function() {
local -r arg="${1:?argument required}"
...
}
Key conventions
- Shebang:
#!/usr/bin/env bsfor library/example scripts;#!/usr/bin/env bashforcore/and entry points. - Add
# shellcheck shell=bashon line 2 for#!/usr/bin/env bsfiles. - Public functions use
module::functionormodule::sub::functionnamespaces. - Constants are
SCREAMING_SNAKE_CASEandreadonly. - Single unix-like style everywhere:
lower_snake_case+module::namespaces; CamelCase/mixedCase are never used (see code-style-guide §2.1). - Use
bs::guardfor idempotency; never hand-roll[[ -n "${__X_SOURCED:-}" ]] && return 0. - Use
bs::source_relativefor relative dependency sourcing. - Use
utils::has,utils::quiet,utils::quiet_err,utils::ignoreinstead of raw redirects. - Strict mode (
set -euo pipefail) is set only in entry points, never in library modules.
Testing
- Unit tests:
tests/unit/test*unit.sh - Integration / system tests:
tests/{integration,network,audit,system,status,data,frameworks}/ - Use
testframework::assert_equal,testframework::assert_true,testframework::assert_false,testframework::assert_command. - New unit tests are auto-discovered by
tests/runalltests.shif placed intests/unit/.
AI workflow
When asked to implement a feature:
- Read the relevant existing modules and tests.
- Check
code-style-guide.mdand the relevant API reference. - Implement the change.
- Add or update tests.
- Run
validatesyntax.sh,validateshellcheck.sh, andrunalltests.sh. - Commit with a clear, concise message; add a joke only if the user asks.
Role-specific prompts
For focused development tasks, use the dedicated prompt files:
.agents/prompts/lib-prompt.md— implement or modifylib/modules..agents/prompts/core-prompt.md— implement or modifycore/modules.
Agent skills
Reusable workflow skills live in .agents/skills/ (Kimi Code / agents-compatible format):
bs-new-lib-module— scaffold a newlib/module (skeleton, guard,@depends, metadata).bs-new-core-module— add acore/module and register it inbootstrap/init.sh+bs doctor.bs-pre-kernel-namespace— write/edit functions inbootstrap/bs.sh(dependency-free helpers usable before the loader).bs-pre-kernel-boundary— check that pre-load code uses no core/lib abstractions; after load they are required.bs-variable-docs— check that module-level variables carry a bilingual# @globalsnippet naming their category (code-style-guide §4.2).bs-write-test— unit/integration test skeleton andtestframework.shassert API.bs-validate— the mandatory validation cycle after any change.bs-docs-sync— keepdocumentation/en/anddocumentation/ru/in sync.bs-commit-style— commit message conventions and history-safety rules.bs-commit-pro— professional commit engineering (atomic intent, staging discipline, bisect/revert safety, series ordering).bs-review-module— skeptical critic pass over a module (bash-pitfalls checklist, §11 lens, prioritized doubt report).bs-check-artifacts— scan for traces of unfinished AI generation and leakage of request/prompt text into code and docs.bs-cli-markdown-style— apply the «markdown simplicity» principle to CLI/interface/output/docs design (7-criteria test, Russian).bs-device-module— write Linux device/hardware modules (evdev/sysfs, binary decoding, test hooks, graceful degradation).bs-ai-toolchain— operate BS as an AI toolbox (discovery ladder, verification loops, generation contracts).
Imported methodology skills (external, verbatim)
General agent-workflow skills imported from obra/superpowers (MIT) and anthropics/skills (Apache-2.0); kept as-is, cross-references between them are intact:
brainstorming— refine intent/design before writing codewriting-plans— bite-sized implementation plans (file paths, verification steps)executing-plans— inline plan execution with reviewtest-driven-development— RED-GREEN-REFACTOR cyclerequesting-code-review/receiving-code-review— review workflow by severitysystematic-debugging— 4-phase root-cause processverification-before-completion— prove the fix, then finishwriting-skills— authoring skills as TDD over process documentationusing-superpowers— meta intro (required background for the others)dispatching-parallel-agents— concurrent subagent workflowssubagent-driven-development— per-task subagents with two-stage reviewusing-git-worktrees/finishing-a-development-branch— branch hygieneskill-creator— skill authoring/evals (anthropics)
MCP / API provider suggestions
- MCP: expose
bsCLI commands (bs doctor,bs list,bs run) plus the validator/test scripts as tools. - API providers: any LLM with function-calling / tool-use support can invoke the validation tools to verify generated code. Examples: OpenAI GPT, Anthropic Claude, Kimi, DeepSeek, Google Gemini, and local models via Ollama/vLLM.
- Context compression: when the full repo is too large, provide only
AGENTS.md, the target module, its tests, andcode-style-guide.md.
