proc-janitor / src
AGENTS.md7 starsChanged 9 months agoMITView on GitHub
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 32,671 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository7 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .github/AGENTS.mdAGENTS.md
- integrations/AGENTS.mdAGENTS.md
- resources/AGENTS.mdAGENTS.md
- scripts/AGENTS.mdAGENTS.md
- tests/AGENTS.mdAGENTS.md
- analyzeSkill
The file
We split this AGENTS.md into the rules it gives an agent
4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 7
All Rust source code for the proc-janitor daemon and CLI.
- Very specific: line 47
fs2 calls: Always use fully qualified syntax: fs2::FileExt::lock_exclusive(&file), not file.lock_exclusive().
- Very specific: line 48
Color output: Use crate::util::use_color() + owo-colors.
- Very specific: line 65
All modules depend on config.rs (except kill.rs and util.rs)
≈ “Common” is an estimate: at least 1 in 5 of the 41,581 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- Parent: ../AGENTS.md --><!-- Generated: 2026-02-06 -->src
Purpose
All Rust source code for the proc-janitor daemon and CLI. Organized as a single-binary crate with module-per-file structure.
Key Files
| File | Description |
main.rs | Entry point, command dispatch (run() → match on Commands) |
cli.rs | CLI argument definitions (clap derive: Cli, Commands, ConfigCommands, SessionCommands) |
daemon.rs | Daemon lifecycle: start/stop/status, signal handling, PID file management |
scanner.rs | Orphan process detection: 3-phase scan (build tree → find roots → collect descendants) |
cleaner.rs | Process termination: clean_filtered() with PID/pattern filters, clean_all() for batch kills |
kill.rs | Shared kill logic: system PID guard (0,1,2), PID reuse check via start_time, SIGTERM→SIGKILL polling |
config.rs | Layered config: defaults < TOML < env vars. Validation, presets, editor support |
config_template.toml | Commented TOML template embedded at compile time via include_str!() |
logger.rs | Structured logging with daily rotation and retention cleanup |
session.rs | Session-based process tracking: TrackedPid, file-locked JSON persistence, TOCTOU-safe |
visualize.rs | ASCII process tree with colored output |
doctor.rs | 8 health checks with colored pass/fail output |
util.rs | Shared utilities: use_color(), check_not_symlink() |
Module Dependency Graph
main.rs → cli.rs (types only)
├→ daemon.rs → config.rs, scanner.rs, cleaner.rs, logger.rs
├→ scanner.rs → config.rs
├→ cleaner.rs → config.rs, scanner.rs, kill.rs
├→ kill.rs (standalone)
├→ config.rs (foundation, depended on by most modules)
├→ logger.rs → config.rs
├→ session.rs → kill.rs
├→ visualize.rs → config.rs, session.rs
├→ doctor.rs → config.rs
└→ util.rs (standalone)For AI Agents
Working In This Directory
- scan vs clean: Scanner NEVER kills. Cleaner ALWAYS kills. Keep this separation strict.
- Scanner is stateful:
Scannerholds aHashMap<u32, OrphanProcess>tracking map. Daemon reuses one instance (scan_with_scanner()), CLI creates fresh ones (scan()). - File locking pattern: Session uses
set_len(0)→seek(0)→write_all→sync_allunder exclusive lock. Never use rename (invalidates lock). - fs2 calls: Always use fully qualified syntax:
fs2::FileExt::lock_exclusive(&file), notfile.lock_exclusive(). - Color output: Use
crate::util::use_color()+ owo-colors. Never hardcode ANSI escape sequences. - XSS prevention: In visualize.rs, use
textContent/serde_json::json!(), neverinnerHTMLwith user data.
Testing Requirements
- Unit tests are
#[cfg(test)] mod testsat the bottom of each file - Tests using env vars must use
#[serial]fromserial_test kill.rstests spawn real child processes for signal testing
Common Patterns
Config::load()at the start of public CLI functionsgrace_period = 0for CLI commands (only daemon uses grace period)anyhow::Result<T>as return type for all fallible functionstracing::warn!()for non-fatal issues,eprintln!()for user-visible warnings
Dependencies
Internal
- All modules depend on
config.rs(exceptkill.rsandutil.rs) cleaner.rsandsession.rsboth depend onkill.rs
External
sysinfo(scanner, kill, daemon, session, visualize)clap(cli.rs only)regex(scanner, cleaner, config)fs2(daemon, session)
<!-- MANUAL: -->Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

