Skip to main content
In this lesson we explore contextual references: how to include or exclude specific parts of your codebase when asking questions. Being deliberate about what you include (and what you leave out) makes assistant responses more focused, accurate, and actionable. Below is a representative snippet from a typical Flask app (app.py). It demonstrates imports, app initialization, a small CSV helper, and a skeleton for obtaining a SQLite database connection. Use this as an example of the kind of file you might add as context.
Never commit real secret keys (like SECRET_KEY) or credentials to source control. Use environment variables or a secrets manager in production.
You can search for files by name and then filter results to a specific file type (for example, only HTML templates). Narrowing the search scope helps you ask targeted questions, such as debugging a template rendering issue without noise from unrelated Python or JavaScript files. Here is a sample set of Jinja2 template fragments you might include as context. Templates supply the assistant with the view-layer behavior and available template functions, improving its understanding of how your Flask views render.
When selecting context, excluding irrelevant files can be just as important as including the right files. For instance, if you’re investigating a template bug, include only template files and exclude unrelated backend logic to reduce noise. Precision yields better suggestions and fewer false positives. Cursor AI’s context system supports several granular selection modes. Use the mechanism that best scopes your question:
  • Files — include a single file by name.
  • Folders — include an entire directory.
  • Code (method/function-level) — include only a specific function or method.
  • Project artifacts — include Docs, Git, Notepads, linter errors, recent changes, or web search results.
Common UI and metadata elements you might see in the Git view help identify where a change originated:
  • PR (Diff with Main Branch)
  • Commit (Diff of Working State)
  • CHAT COMPOSER BUG FINDER
  • app.py — <RepositoryName>
If you are working on a single function, restricting context to that function enables focused recommendations. For example, include only @get_db to ask about SQLite performance tweaks. The assistant can then suggest things like enabling write-ahead logging, tuning PRAGMAs, or adjusting cache size. Examples of context-selection shortcuts:
  • @file — include a specific file
  • @folder — include an entire folder
  • @function — include only a function or method (e.g., @get_db) — useful for targeted analysis
For small helper functions you might include only the function body. Example:
Best practice: include only the files and functions relevant to your question. Exclude everything else to reduce noise and improve answer quality.
Combining the right included contexts (files, functions, commits) with the relevant excluded contexts (large libraries, unrelated services) significantly improves the assistant’s ability to provide precise, actionable guidance. Summary of context selection modes Links and references That’s the essence of contextual references — include exactly the code and project artifacts the assistant needs (and exclude the rest) so you receive focused, reliable answers.

Watch Video