# 1. Find the code with Axon

Source: https://usecns.dev/use-case-axon/

[Use Cases](https://usecns.dev/use-cases/) · **1. Find** → [2. Orient](https://usecns.dev/use-case-orientation/) → [3. Add product knowledge](https://usecns.dev/use-case-product-knowledge/)

**You want to:** change invoice handling without guessing where submission happens or which callers rely on it.

**You leave with:** the implementation's location, a checked caller relationship, and a small list of code to read. Axon is the only organ involved.

## Set up a safe example

Follow the [prerequisites and package availability](https://usecns.dev/use-cases/#before-running-the-examples). This exercise was run with Axon 1.6.4. Run it in a directory where `cns-use-cases` does not already exist. Stay in the new repository throughout all three cases.

The application is deliberately small: billing submits and retries invoices; checkout calls billing. The `send` callback only appends to an array. No payment or network request is made.

```
mkdir cns-use-cases
cd cns-use-cases
git init
git checkout -b main
mkdir -p src/billing src/checkout test
printf '%s\n' \
  '{"name":"cns-use-cases","private":true,"type":"module"}' > package.json
printf '%s\n' '.axon/' > .gitignore

cat > src/billing/invoices.js <<'EOF'
export function processInvoice(invoice, send) {
  return send({ invoiceId: invoice.id, idempotencyKey: invoice.id });
}

export function retryInvoice(invoice, send) {
  return processInvoice(invoice, send);
}
EOF

cat > src/checkout/checkout.js <<'EOF'
import { processInvoice } from '../billing/invoices.js';

export function checkoutInvoice(invoice, send) {
  return processInvoice(invoice, send);
}
EOF

cat > test/invoices.test.js <<'EOF'
import test from 'node:test';
import assert from 'node:assert/strict';
import { processInvoice, retryInvoice } from '../src/billing/invoices.js';
import { checkoutInvoice } from '../src/checkout/checkout.js';

test('retry preserves the original invoice key', () => {
  const requests = [];
  const send = request => requests.push(request);
  const invoice = { id: 'invoice-42' };
  processInvoice(invoice, send);
  retryInvoice(invoice, send);
  assert.deepEqual(
    requests.map(r => r.idempotencyKey),
    ['invoice-42', 'invoice-42']
  );
});

test('checkout submits its own invoice', () => {
  const requests = [];
  checkoutInvoice({ id: 'invoice-73' }, request => requests.push(request));
  assert.deepEqual(requests, [
    { invoiceId: 'invoice-73', idempotencyKey: 'invoice-73' }
  ]);
});
EOF

node --test
git add .gitignore package.json src test
git commit -m 'Add the invoice orientation example'
```

**Check:** two tests pass and the initial commit succeeds. Git needs your existing author identity. The different invoice IDs matter: separate invoices must not accidentally share a key.

## Ask where the behavior lives

```
axon index --full --json
axon status --json
axon search processInvoice --json
```

Look for `processInvoice` in `src/billing/invoices.js`. The result supplies the file and symbol rather than requiring you to know the directory layout first. Open the function and confirm that the submitted key comes from `invoice.id`.

`status` describes the index. Inspect freshness and extraction limits rather than treating exit 0 as a completeness certificate. Rebuild after source changes; an index is not a live view of the editor.

## Ask what calls it

```
axon trace processInvoice --direction incoming --depth 3 --json
```

Look for `retryInvoice` and `checkoutInvoice`, then confirm those calls in the two source files. In a larger repository, use the exact node ID returned by search when several functions share a name. Dynamic dispatch or unresolved relationships may leave gaps; a missing caller is not proof that none exists.

You now have a reading plan: inspect submission and the callers relevant to your task, rather than opening every directory. These name and structural queries do not require embeddings, a relay or a model API key.

## Give an agent a focused task

Use this instruction with an agent authorized to read the repository, or follow it yourself:

```
Locate processInvoice with Axon and inspect its incoming callers.
Open the implementation and the relevant caller files to confirm the relationships.
Explain how retryInvoice and checkoutInvoice reach submission; cite file paths.
Do not change code yet. State any missing or uncertain extraction evidence.
```

Nothing automatically installs an agent integration here. You are giving a reader a question and a way to check the answer.

## What this does not tell you

Axon finds structure. It does not explain why invoice retries need a stable key, run the application tests, or decide whether an edit is safe. That business knowledge is deliberately absent from the structural result.

You can stop here with a useful standalone tool. For a broader first look at an unfamiliar project, [add Soma's orientation map →](https://usecns.dev/use-case-orientation/). Keep this repository and its passing tests.