balatro-mod-dev
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBalatro Mod Development
Balatro模组开发
Create and debug Balatro mods with Steamodded, Lovely, and SMODS.
使用Steamodded、Lovely和SMODS创建并调试Balatro模组。
Quick Agent Selection
快速选择Agent
When researching, spawn the right agent:
| Need to find... | Use agent | Search boundary | Default Backend |
|---|---|---|---|
| Game function implementation | | | claude |
| SMODS API usage/hooks | | | claude |
| How other mods do X | | | claude |
| Lovely patch syntax | | lovely files only | claude |
| Project architecture/exploration | | Current project only | codex |
| Run temp script for data | | N/A (execution) | codex |
| Plan implementation strategy | | Current project only | opus |
| Review code for correctness | | Current project only | opus |
| Synthesize research findings | | Current project only | opus |
Parallel: When researching DIFFERENT sources - spawn multiple agents at once
Sequential: When second query depends on first result
⚠️ MANDATORY: Sub-Agent InvocationALWAYS useto spawn sub-agents. This adapter resolves backend config fromscripts/run_subagent.shand routes through codeagent.mod.config.jsonDO NOT use built-in agent spawning, direct shell commands, or any other method.bash# CORRECT - always use this ./scripts/run_subagent.sh game-source-researcher <<'EOF' [task content] EOF # WRONG - never do this # spawn_agent(...), create_subagent(...), direct codeagent calls, etc.
See for boundaries, workflow patterns, and creating new agents.
references/sub-agents.md进行研究时,选择合适的Agent:
| 需要查找... | 使用Agent | 搜索范围 | 默认后端 |
|---|---|---|---|
| 游戏功能实现 | | 仅 | claude |
| SMODS API用法/钩子 | | 仅 | claude |
| 其他模组实现X的方式 | | 仅 | claude |
| Lovely补丁语法 | | 仅Lovely相关文件 | claude |
| 项目架构/探索 | | 仅当前项目 | codex |
| 运行临时脚本获取数据 | | N/A(执行) | codex |
| 规划实现策略 | | 仅当前项目 | opus |
| 代码正确性审查 | | 仅当前项目 | opus |
| 研究成果整合 | | 仅当前项目 | opus |
并行执行:当研究不同来源时,可同时启动多个Agent
串行执行:当第二个查询依赖第一个查询结果时
⚠️ 强制要求:子Agent调用方式**必须使用**来启动子Agent。该适配器会从scripts/run_subagent.sh读取后端配置,并通过codeagent进行路由。mod.config.json禁止使用内置Agent启动、直接shell命令或其他任何方式。bash# 正确方式 - 请始终使用此命令 ./scripts/run_subagent.sh game-source-researcher <<'EOF' [任务内容] EOF # 错误方式 - 请勿使用 # spawn_agent(...), create_subagent(...), 直接调用codeagent等
如需了解范围边界、工作流模式及创建新Agent,请查看。
references/sub-agents.mdRepo Type Awareness
仓库类型识别
Auto-detection: Compare mod manifest with git remote username.
authorbash
undefined自动检测:将模组清单中的与Git远程仓库用户名进行比对。
authorbash
undefinedGet git remote username
获取Git远程仓库用户名
git_user=$(git remote get-url origin 2>/dev/null | sed -E 's|.*://[^/]+.git$|\1|' | tr '[:upper:]' '[:lower:]')
git_user=$(git remote get-url origin 2>/dev/null | sed -E 's|.*://[^/]+.git$|\1|' | tr '[:upper:]' '[:lower:]')
Get mod author from manifest (first author, lowercase)
从模组清单中获取作者(第一个作者,转为小写)
mod_author=$(jq -r '.author[0] // .author // ""' *.json 2>/dev/null | head -1 | tr '[:upper:]' '[:lower:]')
mod_author=$(jq -r '.author[0] // .author // ""' *.json 2>/dev/null | head -1 | tr '[:upper:]' '[:lower:]')
Compare: match = own, no match = fork
比对:匹配则为自有仓库,不匹配则为分叉仓库
[[ "$git_user" == "$mod_author" ]] && echo "own" || echo "fork"
| Type | Detection | Implications |
|------|-----------|--------------|
| `new` | Empty repo (no files) | Full docs, Logger.lua, localization |
| `own` | Author matches git user | Full docs, standardize structure |
| `fork` | Author differs from git user | Minimal changes, temp logs only |
See `templates/project-rules-template.md` for detailed rules per type.[[ "$git_user" == "$mod_author" ]] && echo "own" || echo "fork"
| 类型 | 检测方式 | 影响 |
|------|-----------|--------------|
| `new` | 空仓库(无文件) | 完整文档、Logger.lua、本地化支持 |
| `own` | 作者与Git用户匹配 | 完整文档、标准化结构 |
| `fork` | 作者与Git用户不匹配 | 最小化修改、仅使用临时日志 |
不同类型仓库的详细规则请查看`templates/project-rules-template.md`。File Naming Convention (Claude & Codex)
文件命名规范(Claude & Codex)
Both Claude and Codex use the same file structure:
| File | Purpose | Git |
|---|---|---|
| Project rules, constraints for AI agents | ignored |
| Mod structure, functions, dependencies, dev status (for handover) | ignored |
| File lists for sync/release scripts | ignored |
| Issues & lessons learned | ignored |
AGENT.md Purpose: Enable seamless handover between agents. Another agent should quickly understand mod structure, functions, dependencies, and current development status without losing context.
Claude和Codex使用相同的文件结构:
| 文件 | 用途 | Git状态 |
|---|---|---|
| AI Agent的项目规则与约束 | 忽略 |
| 模组结构、功能、依赖项、开发状态(用于交接) | 忽略 |
| 同步/发布脚本的文件列表 | 忽略 |
| 问题与经验总结 | 忽略 |
AGENT.md用途:实现Agent之间的无缝交接。其他Agent应能快速理解模组结构、功能、依赖项及当前开发状态,无需丢失上下文。
File Placement Rules
文件放置规则
Only these files belong in root:
.md- ,
README.mdREADME_zh.md - ,
CHANGELOG.mdCHANGELOG_zh.md - ,
AGENT.mdINIT.md LICENSE.md
ALL other files MUST go in
.mddocs/仅以下文件可存放在根目录:
.md- ,
README.mdREADME_zh.md - ,
CHANGELOG.mdCHANGELOG_zh.md - ,
AGENT.mdINIT.md LICENSE.md
所有其他文件必须放入目录
.mddocs/External References (No Symlinks Needed)
外部引用(无需符号链接)
Access reference code directly via absolute paths. No setup required.
可通过绝对路径直接访问参考代码,无需额外设置。
Source Locations (macOS)
资源路径(macOS)
| Resource | Path |
|---|---|
| Game Source (desktop) | |
| Game Source (mobile) | |
| Steamodded Source | |
| Steamodded Lovely | |
| Lovely Docs | |
| Installed Mods | |
| Lovely Logs | |
| 资源 | 路径 |
|---|---|
| 游戏源码(桌面端) | |
| 游戏源码(移动端) | |
| Steamodded源码 | |
| Steamodded Lovely | |
| Lovely文档 | |
| 已安装模组 | |
| Lovely日志 | |
Source Locations (Windows)
资源路径(Windows)
| Resource | Path |
|---|---|
| Game Source | Varies by setup |
| Installed Mods | |
| Lovely Logs | |
| 资源 | 路径 |
|---|---|
| 游戏源码 | 因设置而异 |
| 已安装模组 | |
| Lovely日志 | |
Finding Patterns & Examples
查找模式与示例
When you need to find how something is implemented:
| What to Find | Where to Search | Command |
|---|---|---|
| Game functions | Balatro_src/desktop/ | |
| SMODS API usage | smods/src/ | |
| Lovely patch examples | smods/lovely/ | |
| Other mods' implementations | Installed Mods | |
| Mobile differences | Balatro_src/ios_plus/ | Compare with desktop version |
当你需要了解某项功能的实现方式时:
| 查找内容 | 搜索位置 | 命令 |
|---|---|---|
| 游戏函数 | Balatro_src/desktop/ | |
| SMODS API用法 | smods/src/ | |
| Lovely补丁示例 | smods/lovely/ | |
| 其他模组的实现方式 | 已安装模组 | |
| 移动端差异 | Balatro_src/ios_plus/ | 与桌面端版本对比 |
Key Dependencies
核心依赖项
| Dependency | Purpose |
|---|---|
| Steamodded | Core mod loader, SMODS API |
| Lovely | Lua injection framework |
| Malverk | Texture pack API (AltTexture, TexturePack) |
| 依赖项 | 用途 |
|---|---|
| Steamodded | 核心模组加载器、SMODS API |
| Lovely | Lua注入框架 |
| Malverk | 纹理包API(AltTexture、TexturePack) |
Pattern References
模式参考
Read these files for specific topics:
| Topic | Reference File |
|---|---|
| Lovely.toml syntax | |
| SMODS hooks, config, localization | |
| Desktop vs mobile differences | |
| UIBox, CardArea, draw order | |
| Game source file map + search tips | |
| G.GAME, G.STATES, G.P_* globals | |
| Lua/LuaJIT pitfalls, common mod bugs | |
如需了解特定主题,请阅读以下文件:
| 主题 | 参考文件 |
|---|---|
| Lovely.toml语法 | |
| SMODS钩子、配置、本地化 | |
| 桌面端与移动端差异 | |
| UIBox、CardArea、绘制顺序 | |
| 游戏源码文件映射 + 搜索技巧 | |
| G.GAME、G.STATES、G.P_*全局变量 | |
| Lua/LuaJIT陷阱、常见模组BUG | |
New Mod Setup (type: new)
新模组初始化(类型:new)
Templates in templates/
folder:
templates/templates/
文件夹中的模板:
templates/| File | Purpose |
|---|---|
| INIT.md template (rules) |
| AGENT.md template (repo docs) |
| AGENT.md for Malverk texture packs |
| Script configuration |
| Standard .gitignore |
| Centralized logging utility |
| 文件 | 用途 |
|---|---|
| INIT.md模板(规则) |
| AGENT.md模板(仓库文档) |
| Malverk纹理包的AGENT.md模板 |
| 脚本配置 |
| 标准.gitignore |
| 集中式日志工具 |
Meta Files:
元文件:
| File | Purpose |
|---|---|
| SMODS mod manifest ({ModName}.json) |
| Thunderstore manifest |
| 文件 | 用途 |
|---|---|
| SMODS模组清单({ModName}.json) |
| Thunderstore清单 |
User Docs in templates/docs/
:
templates/docs/templates/docs/
中的用户文档:
templates/docs/| File | Purpose |
|---|---|
| Concise README for docs/ |
| BBCode for NexusMods |
| Issues & lessons learned |
| 文件 | 用途 |
|---|---|
| docs目录下的精简README |
| NexusMods的BBCode格式文档 |
| 问题与经验总结 |
Required User Docs (new repos):
必需的用户文档(新仓库):
Root:
├── README.md, README_zh.md # Main docs (EN/ZH)
├── CHANGELOG.md, CHANGELOG_zh.md # Version history (EN/ZH)
└── {ModName}.json, manifest.json # Meta files
docs/:
├── description.md # Concise README
├── NEXUSMODS_DESCRIPTION.txt # BBCode format
└── knowledge-base.md # Issues & lessons根目录:
├── README.md, README_zh.md # 主文档(英文/中文)
├── CHANGELOG.md, CHANGELOG_zh.md # 版本历史(英文/中文)
└── {ModName}.json, manifest.json # 元文件
docs/:
├── description.md # 精简版README
├── NEXUSMODS_DESCRIPTION.txt # BBCode格式文档
└── knowledge-base.md # 问题与经验总结Basic Mod Structure (new repos):
基础模组结构(新仓库):
{ModName}/
├── main.lua # Entry point, mod registration
├── config.lua # Config defaults (optional)
├── lovely.toml # Lovely patches (if needed)
├── {ModName}.json # SMODS mod manifest
├── manifest.json # Thunderstore manifest
├── mod.config.json # Script configuration
├── Utils/
│ └── Logger.lua # Centralized logging
├── localization/
│ ├── en-us.lua # English (required)
│ └── zh_CN.lua # Chinese
├── assets/ # Sprites, shaders
├── scripts/ # Utility scripts
└── docs/ # Documentation{ModName}/
├── main.lua # 入口文件,模组注册
├── config.lua # 配置默认值(可选)
├── lovely.toml # Lovely补丁(如需)
├── {ModName}.json # SMODS模组清单
├── manifest.json # Thunderstore清单
├── mod.config.json # 脚本配置
├── Utils/
│ └── Logger.lua # 集中式日志工具
├── localization/
│ ├── en-us.lua # 英文(必需)
│ └── zh_CN.lua # 中文
├── assets/ # 精灵图、着色器
├── scripts/ # 实用脚本
└── docs/ # 文档AI Agent Config Templates
AI Agent配置模板
| Folder | Contents |
|---|---|
| Claude hooks.json, init command |
| Codex-specific templates (if needed) |
| 文件夹 | 内容 |
|---|---|
| Claude的hooks.json、初始化命令 |
| Codex专属模板(如需) |
Logging
日志记录
For new/my repos:
自有仓库:
Use (from ):
Utils/Logger.luatemplates/logger-template.lualua
local Logger = require("Utils.Logger")
local log = Logger.create("ModuleName")
log("info", "Initialized")
log("error", "Failed: " .. err)使用(来自):
Utils/Logger.luatemplates/logger-template.lualua
local Logger = require("Utils.Logger")
local log = Logger.create("ModuleName")
log("info", "Initialized")
log("error", "Failed: " .. err)For forks/others' repos:
分叉仓库/他人仓库:
Use temp logs only (remove before PR):
lua
pcall(print, "[Debug] checkpoint: " .. tostring(var))仅使用临时日志(提交PR前需删除):
lua
pcall(print, "[Debug] checkpoint: " .. tostring(var))Utility Scripts
实用脚本
| Script | Purpose |
|---|---|
| Sync mod files to game's Mods folder |
| Create release packages |
| Fix grey borders on sprites |
| Detailed script usage |
| 脚本 | 用途 |
|---|---|
| 将模组文件同步至游戏的Mods目录 |
| 创建发布包 |
| 修复精灵图的灰色边框 |
| 脚本详细使用指南 |
Workflow: Init Any Existing Repo
工作流:初始化任意现有仓库
For ALL non-empty repos (own or fork), ALWAYS do these first:
- Delete folder if exists (legacy symlink approach)
References/ - Move extra files to
.md- only keep in root: README*.md, CHANGELOG*.md, AGENT.md, INIT.md, LICENSE.mddocs/ - Add dev files (if missing): AGENT.md, INIT.md, mod.config.json, scripts/sync_to_mods.sh
- Add Claude config (if missing): ,
.claude/commands/,.claude/hooks/.claude/agents/ - Add hookify rules (if missing): (Opus only for reasoning agents),
.claude/hookify.no-opus-subagents.local.md.claude/hookify.subagent-routing.local.md - Update .gitignore with agent folders
Then for OWN repos: Also check manifest, scripts version (2.0.1), add create_release.sh, Logger.lua
Then for FORK repos: Keep AGENT.md lightweight, use fork-mode INIT.md, don't add release scripts
对于所有非空仓库(自有或分叉),请首先执行以下步骤:
- 删除文件夹(如果存在,属于旧版符号链接方式)
References/ - 将多余的文件移至
.md- 根目录仅保留:README*.md、CHANGELOG*.md、AGENT.md、INIT.md、LICENSE.mddocs/ - 添加开发文件(如缺失):AGENT.md、INIT.md、mod.config.json、scripts/sync_to_mods.sh
- 添加Claude配置(如缺失):、
.claude/commands/、.claude/hooks/.claude/agents/ - 添加hookify规则(如缺失):(仅Opus用于推理Agent)、
.claude/hookify.no-opus-subagents.local.md.claude/hookify.subagent-routing.local.md - 在.gitignore中添加Agent相关文件夹
自有仓库额外步骤:检查清单、脚本版本(2.0.1)、添加create_release.sh、Logger.lua
分叉仓库额外步骤:保持AGENT.md简洁、使用分叉模式的INIT.md、不添加发布脚本
Workflow: Debugging
工作流:调试
- Check for known pitfalls (FFI cdata, nil scoping, boolean normalization)
references/lua-gotchas.md - Check platform (desktop vs mobile)
- Search game source for function
- Check other mods for implementations
- Add logs (Logger.lua for own, temp for fork)
- Check Lovely logs
- If fix fails 3+ times: Document in
docs/knowledge-base.md
- 查看了解已知陷阱(FFI cdata、nil作用域、布尔值标准化)
references/lua-gotchas.md - 检查平台(桌面端vs移动端)
- 在游戏源码中搜索相关函数
- 查看其他模组的实现方式
- 添加日志(自有仓库用Logger.lua,分叉仓库用临时日志)
- 查看Lovely日志
- 如果修复失败3次以上:将问题记录在中
docs/knowledge-base.md
Workflow: Update User Docs
工作流:更新用户文档
When user says "update all user docs":
- Review ALL files: README(_zh).md, CHANGELOG(_zh).md
- Review docs/: description.md, NEXUSMODS_DESCRIPTION.txt
- Update version in {ModName}.json, manifest.json
- Ensure EN/ZH consistency
当用户要求“更新所有用户文档”时:
- 检查所有文件:README(_zh).md、CHANGELOG(_zh).md
- 检查docs目录:description.md、NEXUSMODS_DESCRIPTION.txt
- 更新{ModName}.json、manifest.json中的版本号
- 确保英文与中文文档内容一致
Workflow: Draft PR Message (fork repos)
工作流:起草PR消息(分叉仓库)
Use command. Style: 3-5 sentences, casual tone, what/why/done.
/draft-pr使用命令。风格:3-5句话,语气随意,说明做了什么、为什么做、完成了什么。
/draft-prSub-Agents for Research
用于研究的子Agent
Main agent handles code. Sub-agents handle information gathering via → codeagent routing.
scripts/run_subagent.shShared context: When invoking multiple sub-agents for a task, the main agent must first create as a shared brief. Sub-agents read it for context and write their artifacts (research.md, analysis.md, plan.md, review.md) to the same directory. See → "Shared Task Context" for the full protocol.
.tmp/[taskname]/task.mdreferences/sub-agents.md| Situation | Use | Default Backend |
|---|---|---|
| Research (game, SMODS, mods, lovely) | Research agent | |
| Running temp scripts for data | | |
| Planning, reviewing, synthesizing | Reasoning agent | |
| Writing/editing code | Main agent | — |
| User interaction needed | Main agent | — |
Backends and source paths are configurable in :
mod.config.json- /
agent_backends.research/agent_backends.execution— category defaultsagent_backends.reasoning - — per-agent override (string or
agent_backends.overrides.{agent-name}){backend, workdir} - — where game source, SMODS, mods are located on this machine
source_paths
Model restriction: Opus is allowed only for reasoning sub-agents (strategic-planner, code-reviewer, research-analyst). Research agents use Sonnet; execution agents use Haiku.
Hookify enforcement (requires hookify plugin on-site):
- — Blocks Opus for non-reasoning agents (allows strategic-planner, code-reviewer, research-analyst)
hookify.no-opus-subagents.local.md - — Blocks direct codeagent/route_subagent calls
hookify.subagent-routing.local.md
These are backend hints. Codeagent owns final invocation policy (, ).
resolves config and routes through codeagent automatically — no direct calls.
~/.codeagent/config.yaml~/.codeagent/models.jsonrun_subagent.shcodeagent-wrapperSee for full config resolution, invocation patterns, and parallel examples.
references/sub-agents.md主Agent负责代码处理。子Agent通过 → codeagent路由来处理信息收集。
scripts/run_subagent.sh共享上下文:当为某任务启动多个子Agent时,主Agent必须先创建作为共享任务说明。子Agent会读取该文件获取上下文,并将研究成果(research.md、analysis.md、plan.md、review.md)写入同一目录。完整协议请查看 → "Shared Task Context"。
.tmp/[taskname]/task.mdreferences/sub-agents.md| 场景 | 使用方式 | 默认后端 |
|---|---|---|
| 研究(游戏、SMODS、模组、Lovely) | 研究Agent | |
| 运行临时脚本获取数据 | | |
| 规划、审查、整合 | 推理Agent | |
| 编写/编辑代码 | 主Agent | — |
| 需要用户交互 | 主Agent | — |
后端配置与资源路径可在中自定义:
mod.config.json- /
agent_backends.research/agent_backends.execution— 分类默认值agent_backends.reasoning - — 单个Agent的覆盖配置(字符串或
agent_backends.overrides.{agent-name}){backend, workdir} - — 当前机器上游戏源码、SMODS、模组的存放路径
source_paths
模型限制:Opus仅允许用于推理子Agent(strategic-planner、code-reviewer、research-analyst)。研究Agent使用Sonnet;执行Agent使用Haiku。
Hookify强制规则(需现场安装hookify插件):
- — 禁止非推理Agent使用Opus(允许strategic-planner、code-reviewer、research-analyst)
hookify.no-opus-subagents.local.md - — 禁止直接调用codeagent/route_subagent
hookify.subagent-routing.local.md
以上为后端提示。最终调用策略由Codeagent决定(、)。
会自动解析配置并通过codeagent路由 — 无需直接调用。
~/.codeagent/config.yaml~/.codeagent/models.jsonrun_subagent.shcodeagent-wrapper完整的配置解析、调用模式及并行示例请查看。
references/sub-agents.mdAvailable Commands
可用命令
- - Get familiar with this mod (reads AGENT.md, INIT.md, maps architecture)
/familiar - - Initialize new mod
/init-balatro-mod - - Start sync with watch mode (run once at start)
/sync-mod - - Increment version, update changelogs
/bump-version [patch|minor|major] - - Create release packages (auto-detects version from manifests)
/release - - Fix grey borders on sprites
/fix-sprites <directory> [--preview] - - Review code for redundancy, outdated fallbacks, modularization
/refactor [focus-area] - - Verify fix by checking Lovely logs (auto-detects mod key from repo)
/debug - - Draft PR message (for forks)
/draft-pr - - Audit project health: scripts, hooks, commands, config, file placement, gitignore
/update - - Review all docs (user docs + AGENT.md + INIT.md) for accuracy, staleness, duplication, verbosity
/update-docs - - Update skill based on new knowledge
/update-skill [file|instruction] - - Review session work, capture discoveries (project-scope → AGENT.md, general → skill)
/knowledge
Sub-agents available after setup:
- - Find game functions and injection points
game-source-researcher - - Find SMODS API patterns and usage
smods-api-researcher - - Find how other mods implement features
mod-pattern-researcher - - Find Lovely patch syntax and examples
lovely-patch-researcher - - Extensive codebase exploration (uses codex for token efficiency)
project-explorer - - Run temp scripts and return results
script-runner - - Plan implementation strategy (uses opus for deep reasoning)
strategic-planner - - Review code for correctness and edge cases (uses opus)
code-reviewer - - Synthesize multi-source research findings (uses opus)
research-analyst
- - 熟悉当前模组(读取AGENT.md、INIT.md,梳理架构)
/familiar - - 初始化新模组
/init-balatro-mod - - 启动同步并开启监听模式(启动时运行一次)
/sync-mod - - 递增版本号,更新变更日志
/bump-version [patch|minor|major] - - 创建发布包(自动从清单中检测版本号)
/release - - 修复精灵图的灰色边框
/fix-sprites <directory> [--preview] - - 审查代码冗余、过时回退逻辑及模块化情况
/refactor [focus-area] - - 通过查看Lovely日志验证修复效果(自动从仓库中检测模组密钥)
/debug - - 起草PR消息(适用于分叉仓库)
/draft-pr - - 审计项目健康状态:脚本、钩子、命令、配置、文件放置、gitignore
/update - - 审查所有文档(用户文档 + AGENT.md + INIT.md)的准确性、时效性、重复性及冗长性
/update-docs - - 根据新知识更新技能
/update-skill [file|instruction] - - 回顾会话工作内容,记录新发现(项目范围内容写入AGENT.md,通用内容写入技能)
/knowledge
设置完成后可用的子Agent:
- - 查找游戏函数与注入点
game-source-researcher - - 查找SMODS API模式与用法
smods-api-researcher - - 查找其他模组的功能实现方式
mod-pattern-researcher - - 查找Lovely补丁语法与示例
lovely-patch-researcher - - 深度探索代码库(使用codex以提高令牌效率)
project-explorer - - 运行临时脚本并返回结果
script-runner - - 规划实现策略(使用opus进行深度推理)
strategic-planner - - 审查代码正确性与边缘情况(使用opus)
code-reviewer - - 整合多来源研究成果(使用opus)
research-analyst