# NinjaScript Guardrails - Operational Checklist **Last Updated:** 2026-04-05 Use this checklist whenever touching NinjaScript-facing files. ## Pre-Edit Checks (Required) - [ ] Confirm file is in task scope and allowed by `.kilocode/rules/file_boundaries.md`. - [ ] Verify exact API signatures against official NT8 docs: `https://developer.ninjatrader.com/docs/desktop`. - [ ] Confirm C# 5.0 compatibility using `.kilocode/rules/csharp_50_syntax.md`. ## Lifecycle and Safety Rules (Required) - [ ] Use `OnStateChange` correctly: `State.SetDefaults`, `State.Configure`, `State.DataLoaded`. - [ ] Keep runtime logic out of `SetDefaults` and `Configure`. - [ ] Guard `OnBarUpdate` for series and readiness (`BarsInProgress`, `CurrentBar`/`CurrentBars`). - [ ] In managed order flow, set stop/target before entry on the same bar. - [ ] Do not mix managed and unmanaged order models unless explicitly required. ## API Integrity Rules (Required) - [ ] Do not guess method signatures, enum members, attributes, or overloads. - [ ] Do not use unsupported attributes (example: `[Optimizable]`). - [ ] Do not invent placeholder types/enums unless explicitly confirmed by task/domain requirements. ## Compile Validation Sequence - [ ] Run `.\verify-build.bat`. - [ ] Run required deploy step when NinjaScript source must be synced to NT8. - [ ] Compile in NT8 NinjaScript Editor (authoritative NinjaScript compile gate). ## Compile Failure Learning Loop If any compile issue occurs: - [ ] Capture error fingerprint (`code`, file, line, root cause). - [ ] Apply the smallest safe fix and re-run validation sequence. - [ ] Record durable learning in: - `docs/00-governance/common_failures.md` (symptom + fix) - `docs/00-governance/compile_guardrails.md` (preventive rule) - `docs/00-governance/patterns_and_antipatterns.md` (good vs bad pattern)