Skip to content

Commit 536be57

Browse files
committed
refactor: enforce code quality standards
- plan.py: 1015 → 362 lines (remove 653 dead inline tool defs) - app.py: 1186 → ~900 lines (extract runners to cli/runners.py) - Narrow 26× except Exception → except NoMatches in TUI - Narrow config.py exceptions to ImportError/AttributeError/OSError - Add Code Quality Standards section to agents.md
1 parent 6d2ab72 commit 536be57

7 files changed

Lines changed: 404 additions & 385 deletions

File tree

agents.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,35 @@ The agent's system prompt ([plan.py](retrai/agent/nodes/plan.py) `_build_system_
261261

262262
---
263263

264+
## Code Quality Standards
265+
266+
The agent **must** produce clean, professional code. The following rules are non-negotiable:
267+
268+
### File Size
269+
270+
- **Hard limit: 1,000 lines per file.** If a module exceeds this threshold, refactor it — extract helpers, split into sub-modules, or decompose classes.
271+
272+
### No AI Slop
273+
274+
Do not generate any of the following:
275+
276+
- **Redundant comments** — no `# increment counter`, `# return the result`, or restating what the next line already says. Comments are only for *why*, never for *what*.
277+
- **Excessive try/except** — only catch exceptions you can meaningfully handle. Never wrap code in broad `try: ... except Exception: pass` blocks. Let errors propagate unless there is a concrete recovery strategy.
278+
- **Unnecessary `isinstance` / type-guard clutter** — trust the type system. If a value's type is already narrowed by the signature or a prior check, do not re-check it defensively.
279+
- **Apologetic or verbose inline narration** — no `# TODO: This could be improved`, `# Note: this is a workaround`, or multi-line docstrings that restate the function signature. Keep docstrings to one line unless the function's contract is genuinely non-obvious.
280+
- **Boilerplate logging at every step** — log at boundaries (entry, error, result), not between every line.
281+
282+
In short: write code a senior engineer would be proud to review. Concise, intentional, zero filler.
283+
284+
### Type Safety
285+
286+
- All Python code **must** pass `pyright` in strict mode with zero errors.
287+
- Use precise type annotations everywhere: function signatures, return types, class attributes, and local variables where inference is ambiguous.
288+
- Prefer `TypedDict`, `Literal`, `TypeAlias`, and `Protocol` over `Any`, `dict`, or `object`.
289+
- Never use `# type: ignore` unless accompanied by a justifying comment and a linked issue.
290+
291+
---
292+
264293
## Interfaces
265294

266295
| Interface | Entry Point | Transport |

0 commit comments

Comments
 (0)