Skip to content

Command Code: AGENTS.md user-tier + project-tier content loaded twice when launched from $HOME #730

Description

@problaems

Summary

When Command Code is launched with the working directory set to the user's home
directory ($HOME), the instructions in ~/.commandcode/AGENTS.md are injected
into the system prompt multiple times. In the affected session the content
appeared up to three times, headed by two different Memory from: source paths
that both resolve to the same physical file. The project tier is being loaded
even though $HOME is not a real project.

This breaks the workflow of keeping a single global instructions file as user
tier memory while launching Command Code from $HOME (home directory doubling
as the project root).

Environment:

  • Platform: Windows
  • Working directory ($PWD): C:\Users\probs
  • $HOME: C:\Users\probs
  • The working directory equals $HOME and is also detected as the project root
    (project slug c-users-probs exists under ~/.commandcode/projects/).

Expected Behavior

Per the public memory documentation (https://commandcode.ai/docs, "Memory"),
Command Code loads three tiers of memory — user, project, and subdirectory — and
"every one that exists is loaded." The project tier is the project root's
<project>/AGENTS.md or <project>/.commandcode/AGENTS.md. When $HOME is the
project root, the user tier and the project tier resolve to the same physical
file, so its content is injected twice.

Expected: when the user-tier file and the project-tier file are the same
physical file (home directory == project root), the content should be loaded
exactly once, not once per tier.

Actual Behavior

The system prompt contains the same AGENTS.md content repeated, with these
Memory from: headers (observed across consecutive fresh sessions):

# Memory from: C:\Users\probs/.commandcode/AGENTS.md
<mandatory_instructions>
you must execute shell in ps7!
... (identical content) ...
</mandatory_instructions>

# Memory from: C:\Users\probs/.commandcode/AGENTS.md
<mandatory_instructions>
you must execute shell in ps7!
... (identical content) ...
</mandatory_instructions>

After adding an (empty) placeholder C:\Users\probs\AGENTS.md, the second head
changed to the root path but still contained the full content:

# Memory from: C:\Users\probs/.commandcode/AGENTS.md
# Memory from: C:\Users\probs/AGENTS.md

The model in a fresh session still reported both blocks as containing the full
instructions, even though C:\Users\probs\AGENTS.md was a zero-byte file on
disk (size = 0, sha256 = E3B0C442, the empty-string hash).

Steps to reproduce the issue

  1. Install Command Code (1.32.1) on Windows and create a global instructions
    file at ~/.commandcode/AGENTS.md.
  2. Launch Command Code from $HOME as the working directory
    ($PWD = $HOME = C:\Users\probs), so the home directory is detected as
    the project root (~/.commandcode/projects/c-users-probs is created).
  3. Inspect the system prompt of a fresh session.
  4. Observe that the ~/.commandcode/AGENTS.md content is injected more than
    once, under duplicate Memory from: headers pointing at the same physical
    file.

Command Code Version

1.32.1

Operating System

Windows

Terminal/IDE

Unknown

Shell

cmd.exe

Session file (optional)

Not provided.

Fix prompt (optional)

Route the memory-resolution logic so it de-duplicates blocks whose resolved
source file is identical — dedupe by absolute path or content hash — and/or skip
the project tier when the project root equals $HOME (i.e., when there is no
real project). See the memory tier table in memory.md for the resolution order.

Additional context

The same master content (sha256 aab185f8...) is synced into multiple agents'
directories under $HOME by a personal sync script. Only Command Code
double-loads it:

AAB185F8  C:\Users\probs\.commandcode\AGENTS.md     <- Command Code user tier  (also project tier)
AAB185F8  C:\Users\probs\.dsh\AGENTS.md
AAB185F8  C:\Users\probs\.omp\agent\AGENTS.md
AAB185F8  C:\Users\probs\.pi\agent\AGENTS.md
AAB185F8  C:\Users\probs\Downloads\AGENTS.md

~/.claude/CLAUDE.md (Claude Code) is separate and read by its own agent; it
does not touch ~/.commandcode/AGENTS.md.

The relevant memory-resolution logic is documented in
https://commandcode.ai/docs/memory (bundled as memory.md):

Command Code reads three tiers, and every one that exists is loaded — they add up, they don't replace each other.

| Tier         | Location                                                       |
| ------------ | -------------------------------------------------------------- |
| User         | ~/.commandcode/AGENTS.md                                       |
| Project      | <project>/AGENTS.md or <project>/.commandcode/AGENTS.md        |
| Subdirectory | <subdir>/AGENTS.md or <subdir>/.commandcode/AGENTS.md          |

Project memory
  Both <project>/AGENTS.md and <project>/.commandcode/AGENTS.md are checked, in
  that order — the first one that exists is used, not both.

What I've tried:

  • Created an empty placeholder at C:\Users\probs\AGENTS.md so the project tier
    would resolve to it (first-match) instead of re-reading
    ~/.commandcode/AGENTS.md. Result: the second Memory from: header changed
    to C:\Users\probs/AGENTS.md but still carried the full content despite being
    a zero-byte file. The duplication persisted.
  • Removed the placeholder and restored the sync script (all experimental
    changes reverted; setup back to original state).
  • Searched the product docs and cmd config list for a setting to disable the
    project tier or de-duplicate memory when tiers share a file — no such setting
    exists.

This is not fixable from the user side (short of launching from a different
directory, which breaks the home-directory workflow), because there is no
configuration to stop the project tier from loading a file it shares with the
user tier.

Please let me know if you need any further environment details or the full
session transcript excerpts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions