Setup a git repository with a .gitignore file containing just:
secrets.json
Stage and commit the .gitignore file.
Create a secrets.json file containing some fake secret. Make sure it’s not tracked by git.
Now, open the folder in Cursor.
Ask to build something using an api key without explicitly mentioning the file. My prompt was:
Write a tiny python app that would connect to a backend service: http://www.weather.com/api/isitraining and it passes an api key in the request and prints out the result from the call (don’t worry about it working the service isn’t up yet)
Expected Behavior
According to the documentation, files in .gitignore are supposed to be ignored by Cursor by default. In reality nothing blocks it from reading and printing out the files.
I’m sorry Colin but that is not the way most humans (and the AI agents I shared the documentation with) interpret it. If that’s the intention - saying that .gitignore is only considered by Cursor for indexing - the instructions really should be reworded to make this explicit and clear.
When the docs say “Cursor automatically ignores files in .gitignore” and that section does not talk about indexing at all - it’s very difficult to reach another conclusion and I’m not at all surprised the person in the other ticket called it out.
I do suggest to anyone interested to try this prompt on your favorite set of AI agents: