Skip to lesson
Exit
SDK quickstart in typescript and python1 / 1

2 min lesson

Run one local repository summary

Create one local TypeScript agent, stream its run, inspect the result and dispose the agent.

Check your understanding

Complete the practice "Cursor SDK, one local TypeScript run in a throwaway checkout".

Outcome: The cwd is correct, the status is finished, the request ID is logged, the checkout has no changes and the agent is disposed.

Cursor SDK, one local TypeScript run in a throwaway checkout
Environment key, explicit cwd, finished run, empty diff
DoCreate a clean throwaway checkout, install @cursor/sdk and export CURSOR_API_KEY without writing it to a file.
SeeThe package is installed, the key remains outside the repository and the working tree starts clean.
DoCreate the agent with a model available to the key and local.cwd set to the checkout's absolute path.
SeeAgent.create returns an agent ID that begins with agent- for the local runtime.
TypeSummarize what this repository does. Do not change files.
DoSend one bounded prompt and stream its SDK messages.
SeeThe stream shows assistant, tool and status events from this run.
DoRequire the run to finish and log its request ID beside the result.
SeeThe status is finished and the request ID can correlate the run with logs or support.
DoInspect git diff, then leave the await using scope so the agent is disposed.
SeeThe cwd is correct, the status is finished, the request ID is logged, the checkout has no changes and the agent is disposed.
Learn more

Optional practice

Test yourself on Run one local repository summary

QWhich evidence proves the first local TypeScript run is complete?

Finish the check to continue.