Claude: Prompt Engineering FAQ
All 5 answers
How much Magento context can I cram into one prompt before it falls over?
There is no fixed safe number. Context limits depend on the model, and a long session fills up with everything read so far. Name the files that matter and type @ with a path to include them, point at an existing class as the pattern to follow, and let Claude read the rest when it needs it. For a long search or review, use a subagent so that work happens in its own context window.
How does CLAUDE.md "anchoring" work in practice?
CLAUDE.md is loaded at the start of every session, so specific rules in it shape what Claude does, but it is context, not enforcement. Concrete rules work better than vague ones: “never edit vendor/”, “use db_schema.xml, not raw SQL”, “plugins over preferences”, plus the commands that check the work. Keep it under 200 lines. For anything that must never happen, add a deny rule or a PreToolUse hook as well.
Does role priming ("you are a senior Magento dev") actually help?
It can. Role prompting is one of the techniques in Anthropic’s prompting guide. For a Magento task, the task itself matters more: name the file and the symptom, say what done looks like, and give Claude a check to run, for example php -l, a PHPUnit path or phpcs --standard=Magento2, then ask for the command and its output. A role fits well in a subagent, such as a read-only reviewer.
What is an "output contract" in a prompt?
It is a fixed shape for the answer that you can check. For a scaffold you might ask for the file list first, then each file in its own block with its path on the first line, and no other text. That makes the result easy to review or to pass to a script. It does not make the code correct, so still run a check such as php -l on each PHP file.
What does an "eval loop" look like for Magento prompts?
A loop of write, check and fix. Decide what success looks like first, then give Claude a check it can run: php -l, a PHPUnit path, phpcs --standard=Magento2 or a build exit code. Ask it to run the check and show the command and its output before it says the task is done, and to fix and rerun when it fails. A PostToolUse hook can run php -l after every PHP edit. If the same mistake keeps coming back, add a rule to CLAUDE.md or a hook.
Related FAQ topics
All FAQ topics-
Magento Upgrade
Common questions about upgrading Adobe Commerce / Magento Open Source. -
Hyvä Development
Common questions about Hyvä theme development, migration from Luma, and Hyvä Checkout.
-
Magento Performance
Common questions about Magento performance optimization, Lighthouse... -
Emergency Bug Fixing
Common questions about emergency e-commerce bug fixing across... -
Hiring a Freelance Magento Developer
Questions about Magento project scope, quotes, start dates... -
Magento B2B Development
Common questions about Adobe Commerce B2B, Magento B2B development...