# Quick reference — Sessions 0–6

The essentials to keep beside you while practising. You can print this page.

## Session 0: locate the parts

- **Dining room / frontend:** browser interface and code.
- **Kitchen / backend:** requests, rules and server validation.
- **Pantry / database:** organised information; Sheets in this exercise.
- **Storeroom / storage:** files and references with their own permissions.

Not every app needs a remote server. Here we will connect a browser, Apps Script and Sheets.

**AI helps build; it does not guarantee the result.** Ask → understand → test → fix. Fictional data, authorised accounts and no credentials in the chat.

## Session 1: connect and check

1. **Goal:** one input and one clear result.
2. **Spreadsheet:** `Registres` tab, exact headers in row 1 and document ID located.
3. **Code:** request complete `Codi.gs` and `Index.html` files with server validation and visible errors.
4. **Connection:** configure `ID_DEL_FULL`; the backend uses `SpreadsheetApp.openById`. Run `comprovaConnexio` and review permissions before authorising.
5. **First deployment:** web app, running as your account with access restricted to you or an equivalent restricted option. Use `/exec`.
6. **Tests and change:** valid input, invalid input, reload, access and phone. To keep the link: **Manage deployments → Edit → New version**.

**If something does not fit:** check the document ID (not Script ID), `Registres`, row 1, the account and server error. Do not accept permissions or switch identities to bypass a restriction.

**Completion criterion:** same URL, visible change and preserved data. Sharing and email are later extensions.

Keep file names, function names and exact headers unchanged. Changing the course language does not translate your project data.

## Session 2: one change, one test

1. Recover the correct S1 app. Check name, columns and link.
2. Keep code and spreadsheet; create a copy with fictional data and adjust `ID_DEL_FULL`.
3. Reproduce a small error at **/dev**, record expectations and the exact message; review and apply the smallest fix.
4. Choose **one** improvement. Plan first; then reviewed code, valid-input, invalid-input and regression tests.
5. Review security, permissions and access. AI assists; it does not certify.
6. When it works, update the existing deployment: **Manage deployments → Edit → New version**. Repeat tests at the same **/exec**.

**/dev** runs saved code for editors only. **/exec** runs the deployed version. Do not deploy the deliberate error or make the app public to complete the exercise.

Search and summaries must state their scope. Photos, pagination and record editing are optional advanced challenges. [Test worksheet](../../fitxa-proves-s2-s3.en.html).

## Session 3: code, context and history

- Create a **private** practice repository. Do not store secrets or personal data.
- Open Codespaces after checking quotas and who pays; Copilot has separate conditions. Without an agent, attach context and code to an external chat.
- Bring the existing S2 code; do not rebuild it. Write `context/que-ha-de-fer.md` (product and tests) and `context/arquitectura.md` (technical rules).
- Ask for a small change and review the diff and limits. Sheets: `SpreadsheetApp.openById(ID_DEL_FULL)`, explicit tab and headers.
- **Save:** update a file. **Stage:** select changes. **Commit:** record them locally. **Push:** send them to GitHub. **Pull:** incorporate remote changes; conflicts may occur, so do not apply blindly.
- Deploy manually in Apps Script: test **/dev**, select a new version of the existing deployment and check **/exec**. GitHub does not deploy it by itself.
- Save, commit, push, check github.com and **Stop codespace**. Closing the tab does not stop it immediately; a stopped environment still uses storage.

The “local” copy is in Codespaces, even on a cloud machine. `github.dev` is a lightweight editor without that machine. Neither runs Apps Script locally.

## Cheat sheet — Session 4: A reviewed change

**Clean working copy and updated main → branch → small change → test → commit/push → PR → review → merge → sync.**

- Check the branch in your working copy. Creating it on the web does not switch the Codespace automatically.
- In the PR, base = main and compare = the change branch. Review the latest diff, tests and pending work.
- AI needs the specific diff and context. Verify its findings; it does not guarantee correct code.
- A branch isolates commits, not data: test in an Apps Script copy with fictional data and /dev.
- Merging does not publish by itself. Keep the explicit S2/S3 publishing process until S5 is prepared.
- After merging, check main and update your copy without losing work. Do not force push to recover a shared mistake.

[Test worksheet](fitxa-proves-s4-s5.md) · Prompts: s4.build, s4.review and s4.pr.

## Cheat sheet — Session 5: Publish and verify

**Reviewed plan → adapted kit → credential outside chat → manual run → same /exec → optional automation.**

- [S5 kit and guide](kit-desplegament-s5.md): clasp 3.4.1, Node 24, complete code and original manifest. It needs adapting for other apps.
- Distinguish SPREADSHEET_ID, SCRIPT_ID and DEPLOYMENT_ID. Keep the same deployment and restricted access.
- Authorise your account outside chat. `.clasprc.json` is a credential; `.clasp.json` configures the project.
- Leave AUTO_DEPLOY empty initially. Review the PR and commit before Run workflow on main.
- Push uploads code; creating a version fixes the code; update-deployment updates the same URL. A green job still needs app tests.
- Test a valid record, rejected input, correct spreadsheet and access. Do not mark unperformed tests as passed.
- On error, identify the stage and remote state before retrying. Re-run keeps the original commit.
- Recovery: clear AUTO_DEPLOY, check active runs, restore the previous version and fix the repo. Data recovery is separate.

Private repo protections depend on the plan and exceptions. If ineffective, keep the workflow manual. Prompts: s5.setup and s5.actionDebug.


## Session 6 — A first cycle

1. Define a need and an observable limit. You can continue with Apps Script.
2. Compare services, permissions, costs and export before migrating.
3. Use existing context and code, fictional data and one small change.
4. Record valid, invalid, access, persistence and regression tests.
5. Export and restore a backup; test installation and offline use separately.
6. Declare plan, test and recovery before recording the exercise as complete.

[S6 worksheet](../../fitxa-proves-s6.en.html) · [Local/PWA guide](../../guia-local-pwa-s6.en.html). Prompts: s6.learn, s6.localFile and s6.pwa.
