// EventHandler 在 PO_BEFORE_CHANGE 攔截
if ("A".equals(oldStatus) && "I".equals(newStatus))
throw new AdempiereException("使用中字軌不可降回未啟用(台灣稅法)");
if ("C".equals(oldStatus))
throw new AdempiereException("已用完字軌不可再變更狀態");
雙月申報期別計算
// 從發票月份算期別
int period = (month - 1) / 2 + 1; // 1=1-2月, 2=3-4月 ... 6=11-12月
七個真實踩坑紀錄
坑 1:事件主題比較,一個字毀掉一切
這個 bug 讓狀態驗證完全靜默失效了很久。症狀是:程式碼看起來完全正確,但驗證從來不觸發。
// 錯誤 — 永遠不會觸發
if (topic.endsWith("po_before_change")) { ... }
// 正確
if (IEventTopics.PO_BEFORE_CHANGE.equals(topic)) { ... }
解法:對這類「系統可能已存在」的標準欄位,PackOut.xml 使用固定的 placeholder UUID。PackIn 遇到重複就 UPDATE 而不是 INSERT。升版 UUID 策略:已存在的 field → 保留原 UUID;新增的 field → 才用新的 uuid4。不要為了「整齊」換掉既有 UUID。
坑 7:清除 DB 做全新安裝——FK 刪除順序
當要做「完整卸載 → 清 DB → 重裝」的驗證時,刪資料的順序錯了好幾次。
正確順序:AD_Field → AD_Tab → AD_Window,每一步都有 FK 指向下一個。特別注意:AD_Preference 和 AD_Menu 也會 FK 到 AD_Window,忘記刪這兩個就卡住。另外:ad_package_imp 記錄了 2Pack 安裝歷史,不清掉的話 Incremental2PackActivator 判定「已安裝過同版本」就跳過不執行。
如果重來一次,我們會怎麼做
1. 先建立 PackOut.xml 驗證腳本
每次 2Pack 安裝後自動跑這些 SQL,出問題立刻知道,不用等到 UI 爆炸:
-- SeqNoGrid 是否設定
SELECT tablename, count(*) FILTER (WHERE seqnogrid > 0) ok
FROM ad_table JOIN ad_tab ... JOIN ad_field ...
WHERE tablename LIKE 'TW_%' GROUP BY tablename;
-- _UU 欄位是否 updateable
SELECT columnname, isupdateable FROM ad_column
WHERE tablename LIKE 'TW_%' AND columnname LIKE '%_UU';
-- 確認表存在
SELECT tablename FROM pg_tables WHERE schemaname='adempiere' AND tablename ILIKE 'tw_%';
-- 刪除表
DROP TABLE IF EXISTS adempiere.TW_InvoicePrefix;
DROP TABLE IF EXISTS adempiere.TW_Invoice_Prefix_Map;
為什麼你該關心?因為這些討論不僅涉及技術底層的演進,更直接影響到未來我們如何衡量智慧、保護隱私,以及在 AI 輔助開發的時代中,我們產出的程式碼價值何在。
🤖 AI / 機器學習
【通用人工智慧新挑戰】ARC-AGI-3 基準測試發佈
ARC-AGI 是由 Google 研究員 François Chollet 提出的基準測試,旨在衡量 AI 是否具備真正的「推理能力」而非僅僅是「記憶」。最新的第三版挑戰賽繼續推動研究者開發能應對前所未見任務的演算法,而不僅僅是依賴海量數據訓練。這對於判斷我們距離真正的 AGI(通用人工智慧)還有多遠具有決定性的指導意義。
一項針對 Claude AI 工具生成內容的追蹤顯示,高達 90% 的程式碼最後都提交到了星數(Stars)小於 2 的 GitHub 倉庫中。這反映了 AI 正極大地降低了個人開發與微型專案的門檻,但同時也引發了關於 AI 是否正在製造大量「數位廢棄物」或僅僅是輔助業餘愛好者的討論。這對軟體工程的未來生態提供了獨特的觀測數據。
If < 3: Return to Phase 1, re-analyze with new information If ≥ 3: STOP and question the architecture (step 5 below) DON’T attempt Fix #4 without architectural discussion
同一個檔案第 227 行:
“One more fix attempt” (when already tried 2+) ALL of these mean: STOP. Return to Phase 1.
Use the least powerful model that can handle each role to conserve cost and increase speed. Mechanical implementation tasks (isolated functions, clear specs, 1-2 files): use a fast, cheap model. Most implementation tasks are mechanical when the plan is well-specified.
Testing revealed that when a description summarizes the skill’s workflow, Claude may follow the description instead of reading the full skill content. A description saying “code review between tasks” caused Claude to do ONE review, even though the skill’s flowchart clearly showed TWO reviews (spec compliance then code quality).
## Superpowers Skill Override Rules
### Model Selection
NEVER use haiku for implementation tasks. Follow:
- opus: architecture, code review, cross-file reasoning
- sonnet: all implementation tasks
- haiku: file scanning, directory listing ONLY
### Git Branch
No branch confirmation needed when already on non-main/master branch.
### Debugging Limit
After 3 failed fix attempts, STOP and escalate to user.
Do not attempt Fix #4 without discussion.
用 Claude Code 跑 Agent Team 一段時間後,你可能會發現:明明設定都正確,Claude 還是會跑來問奇怪的問題、用錯 model、或在不該停的地方停下來。這篇文章整理了 Superpowers plugin 裡幾條「你不一定知道」的隱藏規則,以及最簡單的避開方法。
為什麼 Agent Team 會「自己做決定」?
Claude Code 的 Superpowers plugin 提供了一套 skill 系統,讓 Claude 在執行任務時有明確的工作流程可依循。這些 skill 設計上是給通用場景用的,因此內建了一些「省成本、保安全」的預設行為。
問題是:這些預設行為有時候和你的需求相衝突,而且你很難從文件上看出來。
隱藏規則 1:Skill 會自動選最便宜的 Model
來源:subagent-driven-development skill
這條規則直接寫在 skill 裡:
“Use the least powerful model that can handle each role to conserve cost and increase speed. Mechanical implementation tasks: use a fast, cheap model.”
所有 skill 都有這條規則:“Never start implementation on main/master without explicit user consent.” 只要你的 working branch 叫 main 或 master,Claude 每次開始實作前都會停下來問你確認。
這代表你告訴 LEAD「不要動 X 檔案」、「記得用 Y 方式」,subagent 不一定會知道,除非 LEAD 把這些資訊包進去。
避開方法:把規則寫進文件,不要只說給 LEAD 聽
任何重要的約定,放進 AGENTS.md、CLAUDE.md 或 IMPLEMENTATION_PLAN.md。這些檔案 subagent 啟動時會讀到,不依賴 LEAD 的記憶。
隱藏規則 4:Feedback Survey 會擋住畫面
Claude Code 會隨機彈出「How is Claude doing this session?」的評分畫面。這個畫面不是 blocking prompt,按 Enter 沒有用,要按 0 才能 dismiss。
更乾脆的做法是直接關閉它。在 ~/.claude/settings.json 加一行:
{
"feedbackSurveyRate": 0
}
設為 0 後,這個 survey 就永遠不會出現了。
完整 CLAUDE.md 覆寫規則範本
把以下內容加進你的 CLAUDE.md,可以覆寫 skill 的預設行為:
## Superpowers Skill Override Rules
### Model Selection (OVERRIDES subagent-driven-development skill)
NEVER use haiku for implementation tasks. Follow this mapping regardless
of what the skill says about "mechanical" tasks:
- opus: architecture decisions, code review, cross-file reasoning
- sonnet: all implementation tasks (CRUD, API, forms, tests, services)
- haiku: file scanning, directory listing, config comparison ONLY
When dispatching subagents, ALWAYS check AGENTS.md for the assigned model.
If AGENTS.md specifies a model, use it. Do not override with cheaper model.
### Git Branch
Never ask for branch confirmation if already on a non-main/master branch.
Treat any branch that is not named "main" or "master" as pre-approved for
implementation work.
一次性設定清單
以下是只需要做一次的設定,之後每個專案都受益:
設定
位置
效果
"feedbackSurveyRate": 0
~/.claude/settings.json
永久關閉 feedback survey
"defaultMode": "bypassPermissions"
~/.claude/settings.json
工具不再逐一詢問確認
Model 覆寫規則
~/.claude/CLAUDE.md
強制 sonnet 做實作工作
以下是每個新專案開始時的習慣:
git checkout -b dev(避開 main/master 保護規則)
建立 AGENTS.md 並寫好每個 agent 的 model
在 IMPLEMENTATION_PLAN.md 每個 phase 標記 model
為什麼這些規則存在?
這些 skill 是為「通用場景」設計的,預設行為是合理的:
省成本: 對大多數用戶來說,Haiku 做簡單任務確實夠用,費用少一半
保安全: 不讓 Claude 在 main branch 亂動是好習慣
隔離 context: Fresh subagent 避免舊 context 污染新任務
問題不是規則本身,而是當你的專案比「通用場景」複雜時,這些預設值就不夠精準了。透過明確的文件(AGENTS.md、CLAUDE.md)和一次性的 settings.json 設定,你可以讓 Claude 按照你的規格工作,而不是照 skill 的預設值工作。