moon check- Lint and type-check (runs in pre-commit hook)moon test- Run all testsmoon test -p <package> -f <file>- Run specific testsmoon fmt- Format codemoon info- Update.mbtiinterface filesmoon info && moon fmt- Standard workflow before committing
- Use
suberrorfor error types,raiseto throw,try! func() |> ignoreto ignore errors - Use
func() |> ignorenotlet _ = func() - When using
inspect(value, content=expected_string), don't declare a separatelet expected = ...variable - it causes unused variable warnings. Put the expected string directly in thecontent=parameter - Use
!conditionnotnot(condition) - Use
f(value)notf!(value)(deprecated) - Use
for i in 0..<nnot C-stylefor i = 0; i < n; i = i + 1 - Use
if opt is Pattern(v) { ... }for single-branch matching, notmatch opt {} - Use
arr.clear()notwhile arr.length() > 0 { arr.pop() } - Use
s.code_unit_at(i)orfor c in snots[i](deprecated) - Struct/enum visibility:
priv(hidden) < (none)/abstract (type only) <pub(readonly) <pub(all)(full) - Default to abstract (no modifier) for internal types; use
pub structwhen external code reads fields - Use
pub(all) enumfor enums that external code pattern-matches on - Use
let mutonly for reassignment, not for mutable containers like Array - Use
reinterpret_as_uint()for unsigned ops,to_int()for numeric conversion - Use
Array::length()notArray::size() - In moon.pkg.json, use "import", "test-import" and "wbtest-import" to manage package importing for ".mbt", "_test.mbt" and "_wbtest.mbt"
- Use
Option::unwrap_ornotOption::or - Use
const CAPITAL_NAME : Type = exprto define constants, notletorlower_case_name - Use
Ref::newnot@ref.new - Use
pub(open) traitto export a trait - Use
try! s[start:end]to forcely get a slice (StringView)
- Add the following header to new source files (unless the file already has an
existing license header):
// Copyright 2025 International Digital Economy Academy // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License.
When ending a work session, you MUST complete ALL steps below. Work is NOT complete until git push succeeds.
MANDATORY WORKFLOW:
- File issues for remaining work - Create issues for anything that needs follow-up
- Run quality gates (if code changed) - Tests, linters, builds
- Update issue status - Close finished work, update in-progress items
- PUSH TO REMOTE - This is MANDATORY:
git pull --rebase git push git status # MUST show "up to date with origin" - Clean up - Clear stashes, prune remote branches
- Verify - All changes committed AND pushed
- Hand off - Provide context for next session
CRITICAL RULES:
- Work is NOT complete until
git pushsucceeds - NEVER stop before pushing - that leaves work stranded locally
- NEVER say "ready to push when you are" - YOU must push
- If push fails, resolve and retry until it succeeds