Using Claude Code and AGENTS.md with SAP ABAP
TL;DR
- AGENTS.md is a plain Markdown instruction file that Codex, Cursor, GitHub Copilot and Claude Code can all read, so it's the best shared home for ABAP rules.
- In Claude Code, a CLAUDE.md that contains @AGENTS.md imports it. Add Claude-specific notes below the import.
- Keep always-on instructions under about 200 lines. Put long, task-specific procedures such as a clean-core review into a skill in .claude/skills/.
- Run /context or /memory in Claude Code to confirm which instruction files were loaded.
- If SAP's ADT MCP server is connected, tell the agent to use it read-only to check objects and run ATC, and never to use write tools without consent.
Claude Code works in your terminal or editor and reads instruction files from the project folder at the start of each session. For ABAP that's useful, because the things the agent can't guess (your release, your namespace, which objects exist) can be written down once. The same file can serve Codex, Cursor and GitHub Copilot too, if you use AGENTS.md.
AGENTS.md: one file for every agent
AGENTS.md is an open convention: a Markdown file in the repository root with instructions for coding agents. No frontmatter, no special syntax. Several tools read it:
- OpenAI Codex and other agents that follow the convention
- Cursor, in the project root and in subdirectories
- GitHub Copilot, where the nearest
AGENTS.mdin the directory tree takes precedence - Claude Code, which can read it directly in recent versions, or through an import from
CLAUDE.md
If a team uses more than one tool, keeping the ABAP rules in AGENTS.md means one file to maintain instead of four.
The CLAUDE.md import
Claude Code's own file is CLAUDE.md. According to Claude Code's documentation, when a CLAUDE.md exists in your working directory or above it, Claude reads that instead of AGENTS.md by default. The simple, version-independent setup is a CLAUDE.md that imports AGENTS.md with the @ syntax and adds anything Claude-specific below it:
@AGENTS.md
## Claude Code
- Task skills live in .claude/skills/: abap-clean-core-review.
- Prefer plan mode for changes that touch more than one ABAP object.
This is the exact CLAUDE.md in our free lite rules. The imported file is loaded at launch together with CLAUDE.md.
What to put in AGENTS.md for ABAP
Claude Code's documentation recommends keeping each CLAUDE.md under 200 lines, because longer files consume more context and reduce adherence. Imports don't change that: an imported AGENTS.md counts too. So focus on what the agent can't work out from the code:
# ABAP instructions
## Target
- Language version: Standard ABAP. Product: S/4HANA 2023 (SAP_BASIS 7.58).
- Never mix syntax from different releases in one answer.
## SAP objects
- Never invent function modules, BAPIs, classes, CDS views or tables.
- Name every SAP object you rely on and flag the ones to verify.
## ABAP SQL
- Escape host variables with @. Guard FOR ALL ENTRIES with
IF itab IS NOT INITIAL and select all key fields.
## Self-check before answering
- Table expressions don't set sy-subrc. Use line_exists( ) or OPTIONAL.
- BAPI errors are in the RETURN table. No COMMIT WORK in RAP handlers.
- No !=, ++ or "text" literals. Every statement ends with a period.
Replace the target line with your own system. If you don't know the release of every system the code will run on, tell the agent to assume the lowest plausible one.
Skills for longer procedures
Some instructions only matter for one kind of task, such as a code review against Clean ABAP and the clean core levels A to D. Loading that checklist into every session wastes context. Claude Code skills solve this: each skill is a folder in .claude/skills/ with a SKILL.md file, and its description tells Claude when to load it.
---
name: abap-clean-core-review
description: Review ABAP code for Clean ABAP, ABAP Cloud readiness and
clean core level (A-D). Use when the user asks for a code review.
---
# Task: Clean ABAP + clean core review
Return a table: # | Severity | Line/object | Finding | Why | Fix.
1. Correctness: unguarded FOR ALL ENTRIES, SELECT SINGLE without the
full key, COMMIT WORK in RAP or in loops, BAPI RETURN not read.
2. Clean core level of every SAP object used. Mark unknown ones
"verify in Cloudification Repository". Do not guess.
Ask "review this class for clean core" and Claude pulls the skill in.
Path-scoped rules (optional)
If your repository mixes ABAP with other code, Claude Code also supports .claude/rules/*.md files with a paths field in the frontmatter. A rule with paths only loads when Claude works with matching files:
---
paths:
- "src/**/*.abap"
---
# ABAP SQL rules
- Escape every host variable with @ ...
Rules without paths load at launch, like CLAUDE.md. Rules in .claude/rules/ are specific to Claude Code, so other agents won't see them.
Check that the files loaded
Run /context in a Claude Code session and look under memory files, or open /memory, which lists the instruction files Claude Code knows about. If your AGENTS.md doesn't seem to be read, the usual cause is a CLAUDE.md on the path that doesn't import it.
Then test with a release-specific prompt:
Write ABAP for SAP_BASIS 7.40 SP05 that reads ZORDERS
for a list of keys.
With the rules active, the answer should state the release, declare the target table instead of using inline @DATA in the SQL (which needs 7.40 SP08), and guard the FOR ALL ENTRIES.
Connecting to the SAP system
SAP's ABAP development tools for VS Code include an ADT MCP server that external agents like Claude Code can connect to. Per SAP, it's off by default, needs an explicit system allow-list, and is read-only unless you enable editing. If you connect it, say how the agent should use it:
- If an ABAP MCP server is connected, use it to look up objects,
signatures and release state, and to run the syntax check, ATC
and ABAP Unit before answering.
- Read-only by default: never use write tools without explicit consent.
That turns "never invent objects" from a hope into something the agent can actually check. It still doesn't replace your own review: keep ATC and ABAP Unit as the gate before anything is transported.
For the mistakes these files should cover, see ABAP mistakes AI coding assistants make. Using Cursor or Copilot as well? See the Cursor rules guide and the Copilot instructions guide.
Get the rules
Start with the free rules: ABAP for Agents Lite (MIT) has the core rules from this guide, ready for Cursor, Claude Code, GitHub Copilot, Windsurf and AGENTS.md, in English and Portuguese.
Need more? The full Rules Pack (v1.1) has 300+ rules across 20 topics (adding performance, security, RAP, CDS, OData and Fiori, ABAP Cloud and clean core, LUW and locks, BAPIs, ABAP Unit and S/4HANA migration) plus 8 agent skills, with free updates. It is 19 € at launch (29 € after).
More guides
ABAP mistakes AI coding assistants make, and how to prevent them
The pillar guide. Nine repeat mistakes, why models make them, and the rule or code pattern that prevents each one.
FOR ALL ENTRIES with an empty table: the trap and the fix
Why an empty driver table reads the whole database table, the one-line guard, the silent duplicate-row trap, and the alternatives.
Cursor rules for SAP ABAP: a setup guide
Project rules in .cursor/rules for ABAP: rule types, glob patterns for abapGit and ADT files, an always-on core rule and a quick test.
GitHub Copilot custom instructions for ABAP
copilot-instructions.md for the core rules, applyTo-scoped instruction files for ABAP sources, a review prompt file, and where each one works.
Column totals in a Fiori Elements List Report with RAP and CDS
How to get a totals row in an OData V4 List Report from RAP: the two CDS annotations, currencies and units, the table type, and what to check when the sum doesn't show.