agentleFS
jhlee0409jhlee0409/proc-janitor/src/AGENTS.md

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.

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
  1. Very specific:

    All Rust source code for the proc-janitor daemon and CLI.

    line 7
  2. Very specific:

    fs2 calls: Always use fully qualified syntax: fs2::FileExt::lock_exclusive(&file), not file.lock_exclusive().

    line 47
  3. Very specific:

    Color output: Use crate::util::use_color() + owo-colors.

    line 48
  4. Very specific:

    All modules depend on config.rs (except kill.rs and util.rs)

    line 65

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md
<!-- 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

FileDescription
main.rsEntry point, command dispatch (run() → match on Commands)
cli.rsCLI argument definitions (clap derive: Cli, Commands, ConfigCommands, SessionCommands)
daemon.rsDaemon lifecycle: start/stop/status, signal handling, PID file management
scanner.rsOrphan process detection: 3-phase scan (build tree → find roots → collect descendants)
cleaner.rsProcess termination: clean_filtered() with PID/pattern filters, clean_all() for batch kills
kill.rsShared kill logic: system PID guard (0,1,2), PID reuse check via start_time, SIGTERM→SIGKILL polling
config.rsLayered config: defaults < TOML < env vars. Validation, presets, editor support
config_template.tomlCommented TOML template embedded at compile time via include_str!()
logger.rsStructured logging with daily rotation and retention cleanup
session.rsSession-based process tracking: TrackedPid, file-locked JSON persistence, TOCTOU-safe
visualize.rsASCII process tree with colored output
doctor.rs8 health checks with colored pass/fail output
util.rsShared 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: Scanner holds a HashMap<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_all under exclusive lock. Never use rename (invalidates lock).
  • fs2 calls: Always use fully qualified syntax: fs2::FileExt::lock_exclusive(&file), not file.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!(), never innerHTML with user data.

Testing Requirements

  • Unit tests are #[cfg(test)] mod tests at the bottom of each file
  • Tests using env vars must use #[serial] from serial_test
  • kill.rs tests spawn real child processes for signal testing

Common Patterns

  • Config::load() at the start of public CLI functions
  • grace_period = 0 for CLI commands (only daemon uses grace period)
  • anyhow::Result<T> as return type for all fallible functions
  • tracing::warn!() for non-fatal issues, eprintln!() for user-visible warnings

Dependencies

Internal

  • All modules depend on config.rs (except kill.rs and util.rs)
  • cleaner.rs and session.rs both depend on kill.rs

External

  • sysinfo (scanner, kill, daemon, session, visualize)
  • clap (cli.rs only)
  • regex (scanner, cleaner, config)
  • fs2 (daemon, session)
<!-- MANUAL: -->

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.