Skip to content

fix(workspace): preserve existing CLAUDE.md and AGENTS.md on init#63

Merged
christso merged 6 commits intomainfrom
fix/62-preserve-agent-files-on-init
Feb 3, 2026
Merged

fix(workspace): preserve existing CLAUDE.md and AGENTS.md on init#63
christso merged 6 commits intomainfrom
fix/62-preserve-agent-files-on-init

Conversation

@christso
Copy link
Copy Markdown
Contributor

@christso christso commented Feb 3, 2026

Summary

  • workspace init no longer overwrites existing CLAUDE.md or AGENTS.md files when copying from a template source (local or GitHub)
  • Existing files are preserved and only receive WORKSPACE-RULES injection (appended), keeping user content intact
  • Both CLAUDE.md and AGENTS.md had the same bug — both are fixed

Closes #62

Test plan

  • New unit test: existing CLAUDE.md is preserved on init with --from
  • New unit test: existing AGENTS.md is preserved on init with --from
  • New unit test: agent files are still copied when they don't exist
  • All 329 unit tests pass
  • Pre-commit hooks pass (lint, typecheck, test)

🤖 Generated with Claude Code

When running `workspace init`, skip copying agent files from the
template source if they already exist in the target directory. Existing
files still receive WORKSPACE-RULES injection (append) without losing
user content.

Closes #62

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Feb 3, 2026

Deploying allagents with  Cloudflare Pages  Cloudflare Pages

Latest commit: d0bc1c0
Status: ✅  Deploy successful!
Preview URL: https://6b7f3f76.allagents.pages.dev
Branch Preview URL: https://fix-62-preserve-agent-files.allagents.pages.dev

View logs

christso and others added 5 commits February 3, 2026 10:14
Tests asserting "non-workspace dir" behavior were inheriting the test
runner's cwd which may contain .allagents/workspace.yaml, causing the
"No plugins configured" path to be skipped. Set cwd to the temp
directory so tests are isolated from the project's own workspace config.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…NTS.md

Runs the built CLI binary with `workspace init --from` against a
directory that already has CLAUDE.md/AGENTS.md and asserts the
original content is preserved while WORKSPACE-RULES are appended.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The unit test in workspace-init-preserve.test.ts already calls
initWorkspace() directly and covers the same code path without
requiring a pre-built binary.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
These tests spawned `node dist/index.js` and required a build step
before running. They were also brittle (cwd leaked project state into
"non-workspace" assertions). Remove them; the enriched-help and
metadata tests in tests/unit/ and tests/e2e/cli-enriched-help.test.ts
cover the same logic by importing source directly.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace removed e2e binary-spawning tests with unit tests that import
source directly:
- agent-help: flag extraction, command metadata completeness, options/positionals
- json-output: flag extraction and position flexibility

The --help output tests are not replaced since they tested cmd-ts
framework behavior, not our code. cli-enriched-help.test.ts already
covers our metadata structure.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@christso christso merged commit 5d8e3c6 into main Feb 3, 2026
1 check passed
@christso christso deleted the fix/62-preserve-agent-files-on-init branch February 3, 2026 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: CLAUDE.md content is completely replaced by workspace init

1 participant