Files
codex/prs/bolinfest/study/PR-1891-study.md
2025-09-02 15:17:45 -07:00

57 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
**DOs**
- **Use AGENTS.md:** Read user instructions from `$CODEX_HOME/AGENTS.md` only.
```rust
use std::path::PathBuf;
fn load_user_instructions() -> Option<String> {
let mut p = std::env::var_os("CODEX_HOME").map(PathBuf::from)?;
p.push("AGENTS.md");
std::fs::read_to_string(&p).ok().and_then(|s| {
let s = s.trim();
if s.is_empty() { None } else { Some(s.to_owned()) }
})
}
```
- **Ignore empty content:** Treat an empty `AGENTS.md` as no instructions.
```rust
let content = std::fs::read_to_string(&p).ok()?;
let trimmed = content.trim();
let user_instructions = (!trimmed.is_empty()).then(|| trimmed.to_owned());
```
- **Align docs and code:** Update comments and docs to reference `AGENTS.md`.
```rust
/// User-provided instructions from AGENTS.md.
pub user_instructions: Option<String>;
```
- **Centralize the filename:** Use a single constant to avoid drift.
```rust
const USER_INSTRUCTIONS_FILE: &str = "AGENTS.md";
// ...
p.push(USER_INSTRUCTIONS_FILE);
```
**DON'Ts**
- **Dont support instructions.md:** No fallback or dual support with `instructions.md`.
```rust
// Bad: do not keep legacy fallback
p.push("AGENTS.md");
// if not found...
p.pop();
p.push("instructions.md"); // ❌ remove this
```
- **Dont read instructions.md anywhere:** Remove direct references to `instructions.md`.
```rust
// Bad: legacy file name
p.push("instructions.md"); // ❌
```
- **Dont return empty strings:** Avoid treating empty files as valid instructions.
```rust
// Bad: returns Some("") instead of None
let user_instructions = std::fs::read_to_string(&p).ok(); // ❌
```
- **Dont mismatch code and docs:** Avoid comments implying `instructions.md`.
```rust
// Bad: outdated doc
/// User-provided instructions from instructions.md. // ❌
```