This file provides guidance to LLM agents when working with code in this repository.
Community NuttyB is a monorepo containing:
- Lua tweaks for the NuttyB mod for Beyond All Reason (BAR) game (
lua/directory) - A Next.js web application (Configurator) that generates custom mod configurations (
src/directory)
The Configurator allows players to select game tweaks and generates lobby commands + base64-encoded Lua bundles.
bun installbun dev # Start Next.js dev server at localhost:3000
bun build # Build for production
bun start # Start production serverbun run sync -p . # Sync Lua files from local path
bun run sync --help # See all sync optionsThe sync script generates the Lua bundle (public/data/lua-bundle.json) that Configurator uses. Run this after modifying Lua tweak files.
bun test # Run tests (required before commits)
bun lint # ESLint checks
bun knip # Detect unused files and dependenciesThere is a pre-commit hook that automatically runs required checks automatically before committing.
docs/: Documentation files, including contributing guidelineslua/: Lua sources code for NuttyB tweakssrc/app/: Next.js 16 App Router pages/configurator: Main configuration interface/base64: Direct base64 bundle viewer/custom: Custom configuration tools/data: Bundle data viewer
src/components/: React components (uses Mantine UI library)src/lib/: Common reusable business logiccommand-generator/: Generates lobby commands and bundleslua-utils/: Lua file parsing and manipulationencoders/: Base64 encoding utilitiesconfiguration-storage/: Browser storage for user configs
src/hooks/: Custom React hookssrc/types/: Reusable TypeScript type definitionsscripts/: Utility scripts (e.g., sync script)tests/: Unit and integration tests
Two types of Lua files in the lua/ directory:
- Tweakunits: Plain Lua tables (no return statement) that modify unit properties
- Tweakdefs: Executable code wrapped in
do...endblocks for complex logic
Critical: Tweakdefs MUST wrap code in do...end blocks to prevent variable namespace pollution when files are merged.
Example Tweakdef structure:
-- Feature description
-- Authors: Name
-- https://github.com/nuttyb-community/nuttyb
do
local unitDefs = UnitDefs or {}
-- Logic here
end- Tweakdefs MUST use
do...endblocks for proper scoping - Include header with feature name, authors, GitHub URL
- Use local variable aliasing for performance:
local unitDefs = UnitDefs or {} - Always check unit existence before build options modification
- Stylua for formatting (will not work for tweakunits and template Lua files)
- Avoid
anytypes - Use proper TypeScript, reuse existing types - Use functional React components with hooks
- Use Mantine components for UI consistency
- Avoid inline styles; use Mantine props
- Extract business logic from components into utilities/hooks
- Follow existing folder structure and naming conventions
- Prettier for formatting
- ESLint enforces import order, React hooks, and Next.js best practices
- Knip detects unused exports and dependencies
- LF line endings only
When creating pull requests:
- Always check
.github/PULL_REQUEST_TEMPLATE.mdfor the latest format - Include all sections from the template
- Follow PR title conventions: Use Conventional Commits
- Format:
type(scope): description - Example:
chore(configurator): improve settings descriptions - Types:
fix,feat,docs,style,refactor,perf,test,chore
- Format:
Important: Always reference the actual template file at .github/PULL_REQUEST_TEMPLATE.md instead of using cached content, as the template may be updated over time.
- CLAUDE.md - For Claude/Anthropic tools
- .github/copilot-instructions.md - For GitHub Copilot
- GEMINI.md - For Google Gemini tools
- GPT.md - For OpenAI/ChatGPT tools
- .cursor/rules/dev-standard.mdc - For Cursor editor