Claude project discovery detects CLAUDE.md but cannot adopt existing instructions
Summary
When introducing APM into an existing Claude project, apm init --discover detects the root CLAUDE.md but reports it as unsupported instead of offering a way to adopt the existing instructions. In the observed run it also did not report the nested demo-repo/CLAUDE.md.
Environment
- APM CLI: 0.33.0 (cdc1ca5032)
- OS: macOS
- Existing hand-authored root and nested
CLAUDE.mdinstruction files
Steps to reproduce
- Start with an existing Claude project containing a root
CLAUDE.mdand a scopeddemo-repo/CLAUDE.md. - Run
apm init --yes. APM detects Claude and creates anapm.ymltargetingclaude. - Run
apm init --discover --format json. - Run
apm compile --validatebefore manually creating any APM primitives.
Actual behavior
Discovery reports this finding (project-specific absolute paths omitted):
{
"findings": [
{
"path": "CLAUDE.md",
"kind": "native",
"status": "unsupported",
"reason": "Loose native content is not a package. Prepare a supported package manually.",
"dependency": null
}
],
"additions": [],
"applied": false
}
The nested demo-repo/CLAUDE.md was absent from the discovery report. Compilation validation then exits with status 1 and says No APM content found to compile.
The discovery result explicitly calls loose native content unsupported, so this may be an intentional limitation rather than a regression. However, it leaves existing-Claude-project onboarding incomplete: target detection succeeds, but existing instruction content cannot be adopted through discovery.
Expected behavior
Provide a supported adoption/migration path for existing Claude instructions:
- Discover root and nested
CLAUDE.mdfiles. - Offer an explicit opt-in conversion or local package scaffold.
- Preserve nested instruction scope and existing hand-authored files.
- Exclude local/private instruction files such as
CLAUDE.local.md. - If automatic adoption is deliberately unsupported, provide actionable migration guidance in the discovery output.
Workaround
Manually create .apm/instructions/*.instructions.md primitives with applyTo scopes, copying the existing root and nested instructions. Validation and compilation then succeed, but this duplicates instruction sources and requires keeping them synchronized.
No repository instruction contents, credentials, or deployment identifiers are included in this report.
@sesispla @danielmeppiel FYI
Investigation update
This is working as designed for the discover surface that shipped in #2937 (apm init --discover in 0.33.0). It is not a runtime regression.
What shipped
#2937 deliberately narrowed brownfield discovery to local package onboarding only:
- Inventory existing skill/package directories
- Mark installable roots (
SKILL.md/apm.yml) assupported - With
--apply, add a path dependency toapm.yml(no conversion, no copy)
Loose files such as CLAUDE.md are reported as:
status: unsupported
reason: Loose native content is not a package. Prepare a supported package manually.
Docs match that contract: unsupported native content is reported without translation.
Why this feels broken for Claude projects
Target detection (apm init --yes → claude) succeeds because root CLAUDE.md is a harness signal. Discover then refuses to adopt that same file, so apm compile --validate correctly reports no APM content.
Nested demo-repo/CLAUDE.md is absent because the shipped inventory only checks root markers and harness directories (for example .claude/), not arbitrary nested root-context files.
Fix that was removed
#2857 (closed as superseded by #2937) already had this adoption path:
| Piece | Behavior |
|---|---|
RootContextScanner |
Found CLAUDE.md / .claude/CLAUDE.md; treated CLAUDE.local.md as private |
| Classification | ROOT_CONTEXT → CONVERTIBLE via root_context->instruction |
RootContextConverter |
Imported into .apm/instructions/…, originals untouched |
| Nested scope (converter) | Root → applyTo: "**"; nested e.g. frontend/CLAUDE.md → applyTo: "frontend/**" |
Maintainer close on #2857: focus on onboarding (declare local packages into apm.yml), not native-format conversion / harness migration. #2937 kept discovery inventory ideas and dropped conversion.
Nuance: even in #2857, nested */CLAUDE.md conversion was implemented and tested on the converter, but the scanner listed exact paths only, so nested inventory may still have been incomplete.
Suggested direction (for maintainers)
Keep package onboarding as-is. Restore a narrow, opt-in root-context import (not a full #2857 revive):
apm init --discover
apm init --discover --apply --import-context
- Import
CLAUDE.md/AGENTS.md/GEMINI.md(and nested copies) into.apm/instructions/ - Preserve nested
applyToscope; exclude*.local.md - Leave originals untouched
- Do not auto-convert hooks/MCP/commands in the same change
Smaller alternative: only improve the unsupported reason with actionable migration steps (closes the guidance gap, not the adoption gap).
Related: #1130 (broader harness coverage still open), #2937, #2857.
Decision: approve Area: project Scope: Improve guidance for existing Claude projects without adding automatic native-instruction adoption. Explain in detected Claude root-context discovery findings that unsupported means not adopted as an APM package, not invalid for Claude; clarify no-APM-content compile guidance. Document the additive path of retaining native instructions, declaring/installing supported packages, and compiling only APM content, with optional deliberate manual package-authoring guidance rather than required duplicate copies. Done when: Text/JSON/YAML discovery guidance agrees while report keys/statuses, inventory coverage, consent/apply behavior and compile exit behavior stay unchanged; root/nested/private native files remain untouched, with no native contents disclosed, instruction copies created or ownership taken; installed-CLI scenarios cover native-only init/discovery/compile and supported-package declaration plus repeat apply; existing-project, init/compile and usage guidance explains native directory scope, nonrecursive inventory and the source-of-truth tradeoff for manual authoring. Out of scope: Automatic native import, recursive native-file inventory, import flags, conversion/scaffolding, scope translation, private-file import, sync/provenance systems, hooks/MCP migration, broader #1130 approval, README edits without separate approval, assignment, delivery dispatch, PR approval, merge or release commitment. Existing native files do not gain APM dependency locking or cross-project distribution from this guidance repair. Review contact: @danielmeppiel
Decision: accept the guidance-only alternative, not automatic native-instruction import. Keep this issue open for that bounded work.
Thanks @roy2392 for the report and @chkp-roniz for tracing the history and distinguishing the guidance gap from the adoption gap.
For example, a project can already have a root CLAUDE.md for team conventions and frontend/CLAUDE.md for frontend-specific instructions. Claude's native memory behavior handles those files and their directory context. APM does not need to copy or compile them to activate them.
Today, "unsupported" followed by "No APM content found to compile" makes that working setup sound broken. The intended guidance should explain:
- These native files remain in place and are not being adopted as APM packages. Discovery is not an exhaustive scan for nested native instructions.
- Use APM to declare or install actual packages. An existing supported skill folder can already become a local path dependency without copying its source.
- Compile validates APM content, not the existing native Claude instructions. Keep the current no-content exit behavior, but explain the distinction and next steps.
- Authors who deliberately want reusable APM instructions can follow manual package-authoring guidance, deciding the source of truth and scope explicitly. Maintaining two live copies is not a required onboarding step.
This retains the explicit package-onboarding boundary and supersession decision behind #2937. We are declining automatic native import for this issue, not claiming it already works or treating it as promised later. #1130's separate design work is unchanged.
Evidence: an isolated synthetic project exercised the installed Python CLI at 53ccf06d11dd2d675e8ea8c3e2523a6d321c1b79. It reproduced unsupported root discovery, omitted arbitrary nested discovery and compile-validation exit 1. A supported skill then produced one local dependency; repeat apply preserved the manifest. Root, nested and private fixture files stayed unchanged, with no instruction copies created. Adoption and compilation code was compared unchanged at main b2fb1a6fdff6b6dc0fd3b7f59efbcf1aebbe5035; this was not a full rerun at that revision or a Claude runtime test.
The tradeoff is explicit: this makes onboarding understandable but does not put existing native instructions under APM dependency locking or cross-project distribution. No contributor is assigned, no release is promised, and no implementation or PR is approved by this explanation.
Prepared with AI assistance following explicit maintainer confirmation. The separate strict scope record captures the accepted product boundary; it does not dispatch implementation or replace technical review.
@danielmeppiel Thanks for spelling out the decision and for reproducing the behavior. I get the call: guidance-only, no automatic native import, keep the #2937 package-onboarding line.
Honestly, that still feels like a missed opportunity for what discover could be.
The first thing I’d want discover to do is simpler than cross-harness migration:
- Primary: find the agent context already in the repo (
CLAUDE.md, nestedfrontend/CLAUDE.md, and the like), and bring it into APM’s persistent model — soapm.yml/ owned primitives actually record what the project already uses, and the team can review, lock, and reproduce it. - Secondary: once that content lives under APM, use it to move across harnesses (Claude → Copilot/Codex/…).
What shipped only declares already-valid local packages into apm.yml. Loose context never becomes part of APM’s source of truth. So discover can’t even do that first step: map what’s there → keep it under APM. Clearer wording will help people not feel broken; it won’t give them that mapping path.
Leaning on Claude’s native memory doesn’t close it either. Nested CLAUDE.md only loads when Claude touches files in that directory, it isn’t an APM-managed artifact, and it doesn’t make those instructions portable or locked through APM.
I’m fine leaving #3228 as guidance-only. Please don’t treat the broader need as done, though — keep “discover should map existing context into persistent APM config” open under #1130 (or a dedicated follow-up). Migration can stay a later step on top of that.
Hi! I'd like to work on this within the approved guidance-only scope
(https://github.com/microsoft/apm/issues/3228#issuecomment-6317952319):
clarify the discovery reason for detected root-context files such as
CLAUDE.md (consistent across text/JSON/YAML, no key or status changes),
clarify the no-APM-content compile guidance while keeping its exit code,
add installed-CLI scenarios for native-only and supported-package flows,
and update the existing-project, init/compile and apm-usage docs.
No native import, recursive inventory or README changes. I'll link the PR here.
PR is up: #3737