Practical Examples

Three progressive tasks that reuse this course: onboard an unfamiliar repo, ship a multi-file feature with Plan Mode, and install a team workflow with rules + MCP. Paste the prompts into Agent; adapt commands to your repo. Do not run these on production with review turned off.


Example 1: Onboard an unfamiliar repo

Goal: In two hours, name the entry points, the test command, and one safe small change—without guessing.

Setup: Clone any mid-size open-source repo you do not know. Open the repo root in Cursor.

git clone <repo-url> unfamiliar-repo
cd unfamiliar-repo
cursor .
git clone <repo-url> unfamiliar-repo
cd unfamiliar-repo
cursor .

Ctrl+I / Cmd+I, then send in order:

Explain this codebase. Point me to the main entry points, key modules,
and anything I should read before making changes.
Quote the exact commands this repo uses for install, test, lint, and
dev server. Prefer package.json / Makefile / pyproject.toml / go.mod.
Do not invent scripts.

Run the install and test commands it quoted (examples):

# follow whatever the repo actually printed
npm ci
npm test
npm ci
npm test

If tests fail for missing secrets, paste the error back: These tests failed on a clean clone. Which env vars are required? Do not weaken tests.

Then ask for three small improvements and approve one (see Quick Start). Review the diff and rerun the same tests.

Done when:

CheckPass
You can point at the entry fileYes / no
The test command came from the repo, not inventionYes / no
You merged one small diff and tests match the clean clone (or you understand the failure)Yes / no

Example 2: Multi-file feature with Plan Mode

Goal: Add a read-only /health (or equivalent) endpoint that does not touch auth, plus a test in the repo’s style.

Setup: Pick an app that already has an HTTP layer (Express, FastAPI, Rails, Go net/http, …). Create a branch:

git checkout -b practice/health-endpoint

Shift+Tab into Plan Mode and send:

Add a public health endpoint that returns JSON { "ok": true }.

Constraints:
- Reuse the existing HTTP stack and folder layout
- Do not change authentication or existing routes
- Do not add dependencies
- Follow existing test style

Research the repo, ask clarifying questions, and write a plan that lists
every file, the test command, and rollback. Do not edit files until I approve.

Review the plan:

  1. Files are only the route + test (plus whatever register the framework requires)?
  2. The test command already exists?
  3. No “refactor while we are here”?

Save to workspace, e.g. docs/plans/health-endpoint.md. Approve the build. Afterward:

Run only the commands listed in the plan. Paste stdout and exit codes.
If a check failed, fix it without expanding scope.

Run them yourself too. If the implementation drifted: restore a checkpoint or git restore ., tighten the plan, build again (see Plan Mode).

Done when:

CheckPass
The plan was approved before the buildYes / no
curl or the test client returns {"ok":true} (or the repo’s equivalent shape)Yes / no
Existing auth tests still passYes / no
The diff matches the plan’s file listYes / no

PowerShell probe (change the port):

Invoke-RestMethod http://127.0.0.1:3000/health
curl -s http://127.0.0.1:3000/health

Example 3: Team workflow with MCP + rules

Goal: A new teammate (or future you) clones the repo and Agent already follows the same norms, plus one MCP server they can call safely.

3a. Check in rules and shared instructions

At the repo root:

New-Item -ItemType Directory -Force -Path .cursor\rules, docs\plans | Out-Null
mkdir -p .cursor/rules docs/plans

.cursor/rules/team.mdc:

---
alwaysApply: true
---

- Read AGENTS.md before the first edit in a session
- Do not add dependencies without asking
- Never commit `.env`, credentials, or `mcp.json` secrets
- Prefer Plan Mode when a task will touch more than five files

Root AGENTS.md:

# Agent instructions

- Install: use the commands already documented in README
- Test: use the existing script (do not invent a new runner)
- Public API changes require a plan saved under docs/plans/

Commit those files. Start a new Agent chat and say: Add lodash for a one-liner. A well-ruled agent should refuse or ask first.

3b. Project MCP (no secrets in Git)

Commit a secret-free server in .cursor/mcp.json. Tokens go through ${env:NAME}. Shape only—replace with a real, reviewed server:

{
  "mcpServers": {
    "docs": {
      "command": "npx",
      "args": ["-y", "mcp-server"],
      "env": {
        "API_KEY": "${env:API_KEY}"
      }
    }
  }
}

Interpolation and transports: MCP. Protocol depth: MCP course.

Enable the server in Customize; confirm Output → MCP Logs. Then:

Use only the enabled MCP tools to fetch the current issue/doc titled
"<name>". Summarize acceptance criteria. Do not edit product code.
Then draft a Plan Mode plan that implements those criteria with our
AGENTS.md constraints.

3c. Team contract

AgreementPractice
Each person signs into Marketplace / OAuth locallyDo not share refresh tokens
SecretsOS env or a gitignored local .env
ReviewPRs that touch rules / MCP must be reviewed; tool-arg screenshots optional
Shared with CLI agentsOne AGENTS.md; Cursor-only globs stay in .mdc (see Workflow)

Done when:

CheckPass
Rules apply on a second machine (or second window) opening the same repoYes / no
Agent does not add a dependency without askingYes / no
MCP appears under Available Tools; logs show no auth errorsYes / no
The plan cites the MCP summary and obeys AGENTS.mdYes / no

Anti-patterns

Anti-patternFix
Skip the map, “fix every bug”Example 1 first
Agent edits before Plan approvalWrite Do not edit files until I approve
API keys in mcp.json${env:NAME} + gitignore
Three conflicting rule filesShared prose lives in AGENTS.md only
Checkpoints instead of GitBranch + commit when the exercise ends

Next

评论