Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .build/build-rat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@
<!-- legal files -->
<exclude NAME="NOTICE.txt"/>
<exclude NAME="LICENSE.txt"/>
<!-- AI agent instruction files -->
<exclude NAME="AGENTS.md"/>
<exclude NAME="CLAUDE.md"/>
<!-- misc -->
<exclude NAME="**/*.patch"/>
<exclude NAME="**/*.diff"/>
Expand Down
79 changes: 79 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Agent Instructions for Apache Cassandra

> These instructions apply to all AI-assisted contributions to `apache/cassandra`.

## Apache Cassandra
Apache Cassandra is a NoSQL distributed database. This is the official Git repository

## Environment

- Java 11 (default) or 17.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we support 21 in runtime now as well

- Python 3 for `cqlsh` and dtests.
- Apache Ant >= 1.10 for all builds. Do NOT attempt to use Maven, Gradle, or any other build tool. Cassandra uses Ant exclusively.
- Do NOT attempt to install dependencies, you do not have Internet access

## Build

```bash
ant build # compile all classes (includes Accord submodule)
ant jar # build the main JAR
ant clean # remove locally created artifacts
ant realclean # remove entire build directory and downloaded artifacts
```
Comment on lines +15 to +22
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a blocker for this PR at all, but i find its best to not let the harnest know / touch ant as its wasteful for tokens. Locally I have 2 scripts

ai-ci-test <test> -- runs the test and strips the output so its "success" *or* the failing task
ai-build -- `ant clean && ant build` but strips the output so its "success" or the failing task


Do NOT run `ant build` if you only need to verify a small change compiles.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do you test compile then?


## Testing

- Do NOT run the entire test suite(`ant test`). Run only the specific test(s) relevant to your change.

```bash
# Run a single unit test class
ant testsome -Dtest.name=org.apache.cassandra.service.StorageServiceServerTest -Dtest.methods=testGetAllRangesEmpty
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Differentiating how to run unit vs. integration could be useful. Though I think it's more likely that just adding a SKILL.md for running tests that has a distilled extraction of guidance from build.xml is probably the better way to do that.

So - maybe a quick example here + pointing to build.xml w/some string bread crumbs to know what to search for could be a decent 1st step.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an area i feel we should have a script. For example the above is 100% wrong, and is what 90% of Cassandra dev use =D

CI uses testclasslist which has different JVM arguments, so if you test using testsome and it fails in CI you will struggle to figure out why... they are not the same!

We also have different test scopes and they have their own command or special flags... this is way too much to put in a agents file and really should just be a script to make it idiot proof (LLMs do stupid things, try to make this deterministic when possible)

```

- When fixing a bug, first create a regression test that reproduces the failure, then implement the fix and verify.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a blocker for this patch, but this is an area where skills can help. How to work with CQLTester, how to work with jvm-dtest, how to work with qt or stateful, how to work with the simulator; etc.

first create a regression test that reproduces the failure

do we have any example JIRA where this went well? I find claude makes really horrible tests. It will try to create a fake unit test that makes no sense then it defines success as it made the logic handle its test... but you actually go through Cassandra and everything is broken.

- Provide test(s) coverage for all new or modified code.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how? this is vague so LLMs are likely to make up random numbers; if we care about this (which we don't track) it should be deterministic


## Linting and Code Checks

```bash
ant check # runs checkstyle, RAT license check, and builds
ant checkstyle # checkstyle only
Comment on lines +41 to +42
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason the harness should use checkstyle vs check? the more we add the more likely it will do the wrong thing

```

## Code Style
Cassandra enforces style via Checkstyle (`ant checkstyle`). Key rules are included in `checkstyle.xml` file.
General style:
- 4-space indentation, no tabs.
- Braces on a new line below control statements (Allman style).
- Brace-less style for single-line control statements.
- Match existing code style in the file you are editing.
- All new files must include the Apache License 2.0 header.
- Concise English documentation is required for complex classes and methods; trivial ones may not require them.
Comment on lines +45 to +53
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly this is misleading and the actual style guide is at https://cassandra.apache.org/_/development/code_style.html

The only way for a agent to know our style guide is to read that rule; and this is manual and lacking deterministic checks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That style guide comes from the code right? We could just have a .md redirect pointing to that file for digging into specifics around style. Not sure when an LLM would be triggered to check that vs. just inferring from the local context from files.

Copy link
Copy Markdown
Contributor

@dcapwell dcapwell Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this in the website project?

$ # in cassandra dir
$ fd code_s
$

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✓  ~/src/github/apache/cassandra-website git:(trunk) $ fd code_s
site-content/source/modules/ROOT/pages/development/code_style.adoc


## Git Workflow
- Do NOT commit unless explicitly asked.
- Commit messages should reference the JIRA issue. Disclose that AI assistance was used in the PR description.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

honestly I think we should remove this. Logically this is only needed if the committer pushes this on the author (many don't), and is done after the review.

For agent files you need them to work in 100% of sessions, and this section isn't applicable majority of the time.

For example, how does it learn the JIRA?, how does it learn the reviewers? how does it learn that a reviewer gave code feedback and should be be included as a co-author? what should the commit message be and is it in-sync with JIRA (we are required to push context to JIRA as a source of truth)?


```
CASSANDRA-XXXXX: Brief description of the change
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the format does not match the agreed commit message described in https://cassandra.apache.org/_/development/how_to_commit.html

Author: Your Name <your.email@example.com>

Co-authored-by: GitHub Copilot
Co-authored-by: Claude
Co-authored-by: gemini-code-assist
```
Comment on lines +63 to +66
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think this is agreed to yet. Mick proposed in slack (informal) to use the Linux Kernal way of Assisted-by; as of this moment we don't have a syntax agreed to.


- Do NOT modify submodule references without understanding the implications. Submodule changes must be committed and pushed before the parent Cassandra commit.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this comment? this tells the LLM to hack around Accord rather than make clean fixes. Why are we asking harnesses to own git?


## Boundaries

- 🚫 Never modify generated files in `src/gen-java/` — they are built from `src/antlr/` grammars.
- 🚫 Never modify files in `lib/` — these are managed dependencies.
- 🚫 Never commit secrets, credentials, or API keys.
- 🚫 Never run the full test suite (`ant test`) — it takes hours. Run targeted tests only.
- 🚫 Never bypass Checkstyle violations without a suppression comment explaining why.
- 🚫 Never create summary or documentation files unless explicitly asked.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i feel like this should be removed; harnesses are better at maintaining docs than us humans... so actually making sure features are documented should be desired?

- ⚠️ Ask before modifying the CQL grammar (`src/antlr/Cql.g`) — changes cascade widely.
- ⚠️ Ask before modifying `modules/accord/` — it is a separate repository.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a git thing, this tells the harness to hack when the proper solution is to update accord.

1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@AGENTS.md
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't a symlink in git, so when you checkout you get

$ cat CLAUDE.md
@AGENTS.md%