nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Feature] Load AGENTS.md from the user config dir and from subdirectories

Open akramcodez opened this issue 4 weeks ago • 3 comments

Description

Load instruction files from more than one place: a user-level AGENTS.md in the nanocoder config dir, and AGENTS.md files in subdirectories of the project, in addition to the one at the project root.

Use Case

Today appendAgentsMd in source/utils/prompt-builder.ts reads exactly one file, <project root>/AGENTS.md. Two things follow from that:

  • Personal preferences that apply to every project ("never use em dashes", "use pnpm", "keep commit messages to one line") have to be copied into each repo's AGENTS.md, or left out. There is no user-level file.
  • In a monorepo, packages/api and packages/web often have different test commands and conventions. A single root file either gets very long (and is sent on every request, which hurts on small local models) or leaves the per-package rules out.

Proposed Solution

  1. If <config dir>/AGENTS.md exists (same place agents.config.json lives, so NANOCODER_CONFIG_DIR is respected), include it first.
  2. Keep the project root AGENTS.md as it is now.
  3. For nested files, add the closest AGENTS.md between the working directory and the project root once the agent starts reading or editing files under that directory, so nothing extra is sent for packages the session never touches.

Closer files should come later in the prompt so they take precedence on conflicts. The existing tune.includeAgentsMd switch and the nano profile should turn all of this off together.

Alternatives Considered

  • /remember and the memory store cover facts about a project, but not standing instructions that should apply everywhere, and they are not plain text a user can edit and version.
  • Telling users to symlink one file into every repo. It works but is easy to forget and does not help the monorepo case.

Additional Context

  • [x] I have searched existing issues to ensure this is not a duplicate
  • [x] This feature aligns with the project's goals (local-first AI assistance)

Implementation Notes (optional)

The project root already comes from getProjectRoot(), so walking up from the session cwd to that root is cheap. A size cap per file, with a visible "truncated" note, would keep a large nested file from eating the context window on small models. Other agents do the same thing: Codex reads a global AGENTS.md plus one per directory level, and OpenCode also supports a global rules file next to the project one.

akramcodez avatar Nov 06 '26 09:11 akramcodez

i would like to work one this one @addyCooks or @akramcodez could one of you assign this to me?

Vishesh-Verma-07 avatar Nov 06 '26 13:11 Vishesh-Verma-07

Thanks for your interest @Vishesh-Verma-07! You already have a few issues assigned to you, so please finish those first. Once they're done, ping me here and I'll assign this one to you.

addyCooks avatar Nov 07 '26 08:11 addyCooks

done with previous ones. can you assign this

Vishesh-Verma-07 avatar Nov 07 '26 15:11 Vishesh-Verma-07