Compass项目核心编码准则
deepcode-cardinal-rules
Compass 项目的核心准则。在编写、审查或设计代码架构时使用,以避免常见的 LLM 编码错误。涵盖 harness 与应用分离、死代码检测以及构建优先原则。
- License 许可
- MIT
- 所属仓库
- jtrefon/compass
- 最近更新
- 2026-11-14
- Stars
- ★ 3
- Forks
- 0
01 前言 Front Matter
- name
- deepcode-cardinal-rules
- description
- Cardinal rules for the Compass project. Use when writing, reviewing, or architecting code to avoid common LLM coding mistakes. Covers harness-vs-app separation, dead code detection, and build-first discipline.
02 资源文件 8
- 参考文档references/concurrent-request-distribution.md2.5 KB
- 参考文档references/credit-aware-load-balancing.md2.8 KB
- 参考文档references/errors.md323 B
- 参考文档references/examples.md87 B
- 参考文档references/health-based-routing.md1.7 KB
- 参考文档references/model-based-load-balancing.md1.3 KB
- 参考文档references/monitoring-load-distribution.md1.1 KB
- 参考文档references/multi-key-load-balancing.md1.7 KB
03 SKILL.md 正文
DeepCode Cardinal Rules
These rules MUST be followed in every session. Violations cause cascade failures.
Rule 1: Harness Orchestrates — Never Implements
The harness (test/verification code) calls production code. It never replaces it.
✅ CORRECT: harness.swift
let tool = ReadFileTool(...) // production AITool
let result = try await tool.execute(args)
XCTAssert(result.contains("content"))
❌ WRONG: harness.swift
func readFile(path: String) -> String {
return FileManager.default.contents(atPath: path) // reimplementing tool logic
}
Checklist before writing harness code:
- [ ] Does this logic already exist in the app target? If yes, CALL it, don't reimplement.
- [ ] Am I creating a mock that replaces app behavior? Mocks are only for external dependencies (network, filesystem, AI service).
- [ ] Is the harness creating its own
ToolDefinitionorAITool? Use the production ones.
Penalty: Any harness code that duplicates app logic must be deleted and rewritten to call the app code.
Rule 2: Build Before Claiming Progress
Every change must compile before the next change is started.
❌ WRONG:
Change file A → Change file B → Change file C → Build → FAIL (3x debugging)
✅ CORRECT:
Change file A → Build → Change file B → Build → Change file C → Build
Exception: Documentation, markdown, and prompt files don't need compilation checks.
Rule 3: Dead Code Must Be Identified, Not Just Created
Before creating new code, inventory what already exists.
When asked to "fix mode X" or "add feature Y":
- Search for all files that reference the mode/feature
- Trace the runtime path (who calls what)
- Identify dead vs live code
- Report findings before implementing
Test for dead code: If a file has ZERO references from outside its directory subtree, it is dead.
Rule 4: One Production Path — One Working Path
There must never be two competing implementations of the same concern.
❌ WRONG:
Services/Tooling/ToolExecutor.swift (new, broken)
Services/AIToolExecutor.swift (old, working)
✅ CORRECT:
Keep one working path. The other is either deleted or clearly marked as PHASE 2+.
When a duplicate exists:
- Route the new feature through the WORKING path
- Mark the dead code with a header comment:
// PHASE 2+ — NOT ON RUNTIME PATH - Do NOT attempt to fix both paths simultaneously
Rule 5: Trace the Telemetry Before Diagnosing
When something doesn't work, look at what the system ACTUALLY did — not what you think it did.
- Run the failing scenario
- Check
ai-trace.ndjson— was the AI called? With what tools? - Check
app.ndjson— were there errors? - Check
crash.ndjson— did it crash? - Check the session JSON — what mode was active? What messages exist?
Only after telemetry analysis, make code changes.
04 同仓库更多 Skills
MLX Swift 本地大模型运行
swift-mlx-lm
MLX Swift LM——使用 MLX 在 Apple Silicon 上运行大语言模型(LLM)和视觉语言模型(VLM)。涵盖本地推理、流式输出、wired memory 协调、工具调用、LoRA 微调、嵌入向量和模型移植。
Codacy本地分析问题修复
codacy-fix-issues
使用 Codacy 本地分析查找并修复项目中的问题。
Codacy代码覆盖率检查
codacy-check-coverage
使用 Codacy 检查项目的代码覆盖率。