# Editing Safely

## Editing Safely

**Skill level:** Complete beginner

Nothing you change in Covena is permanent if you keep checkpoints. These habits make every edit safe to try, whether you edit by hand or with AI.

### The Safe Editing Loop
<Steps>

1. **Run the site** with `npm run dev`, so you see each change as soon as you save.
2. **Change one thing**, save, and look at the page. Watch the terminal too: an error or a yellow warning points at the file to fix.
3. **Make the window narrow** to see the phone layout, and open the mobile menu. Longer names and labels show their problems here first.
4. **Check your other languages:** open the same page under `/fr/` and `/ar/`. Each language reads its own folder, so change each one. Arabic pages read right to left.
5. **Save a checkpoint** when it works (see below).
6. **Repeat.**

</Steps>

Small steps make problems easy to find: if the page breaks, it was the last change.

### Save Checkpoints With Git
In VS Code's **Source Control** panel (or the terminal):

```bash
git add .
git commit -m "Change office hours and hero text"
```

- **See what changed** since the last checkpoint: click a file in the Source Control panel. Removed lines are red, added lines are green.
- **Undo changes to one file**: right-click it in Source Control and choose **Discard Changes**.
- **Undo everything since the last checkpoint**: `git restore .` in the terminal.

No git? Copy the whole Covena project folder (without `node_modules/`) before a big change, and name the copy with the date.

### Before You Change Code
Content files are hard to break. Components and styles are easier to break and harder to fix. Before you edit anything in `src/layouts/`, `src/lib/`, or `src/styles/`:

- check whether the change can be made in a content file or `config.toml` instead. It usually can: a page can change any of its sections with a named block, hide one with `enable: false`, and pick its header and footer in its page file
- save a checkpoint
- run `npm run astro-check` afterwards

### Edit Slugs With Care
Files point at each other by slug, the file name without `.md`. An attorney's `office` names an office file, a practice area's `relatedAttorneys` lists attorney files, and a result's `practice` and `attorneys` do the same. When you rename or delete an entry:

- rename or delete it in every language folder (`english`, `french`, `arabic`)
- search the project for the old slug and update every list that names it. For most of these lists, the build prints a `No entry named` warning when a slug has no file
- check the menus in `src/config/menu.<lang>.json`, which link to pages by address

### Keep The Results Disclaimer
Every result card and result page shows "Past results do not guarantee a similar outcome. Every case is different." from `results.disclaimer` in `src/i18n/<lang>.json`. You can reword it in each language, but don't empty it, and keep it next to any past outcome you add elsewhere.

### Run The Checks
```bash
npm run astro-check   # finds mistakes in code and in content files that have a schema
npm run build         # builds the full site, as your host will
npm run verify        # every check: astro-check, tests, formatting, build, links, languages
```

Run `astro-check` and `build` before every deploy, and `verify` after bigger changes. Stop `npm run dev` first, and run the commands one after the other, not at the same time.

`astro-check` doesn't catch a misspelled option in a section file or a page block with a wrong name, so the safe editing loop above (look at the page after each change) is your check for those. Read the yellow lines in the `npm run build` output: `[site]` means `baseUrl` is still empty.

<Aside type="caution">
  Never edit files in `.astro/`, `dist/`, or `node_modules/`. They are
  generated and your changes would be lost. That includes
  `.astro/config.generated.json`: edit `src/config/config.toml` instead.
</Aside>