Prerequisites
- Python 3.x
- Flask (https://flask.palletsprojects.com/)
- SQLite (https://www.sqlite.org/)
- Basic HTML/CSS (for templates)
Sample Flask Application
Never use a hardcoded
SECRET_KEY in production. Store secrets securely using environment variables or a secrets manager.Querying Best Practices at a Glance
| Practice | Description |
|---|---|
| Be Specific & Clear | Define the framework, library, and goal in your query |
| Provide Just Enough Context | Share only the code or data snippets relevant to your issue |
| Use Structured Formats | Present examples in JSON, YAML, tables, or bullet lists |
| Specify Output Formats | Ask for code snippets, pseudocode, or documentation excerpts |
1. Follow Your Querying Guidelines
Maintain a concise set of rules when interacting with LLMs:- Be specific and clear: “How do I implement JWT authentication in Flask?”
- Provide context: Mention Flask extensions or database libraries you’re using.
- Use structured formats: Wrap code in markdown, share JSON schemas, etc.
- Specify output formats: Request a complete function, YAML config, or a step-by-step tutorial.

- Instead of “How do I do authentication?”, ask “What is the best way to implement JWT authentication in Flask using PyJWT?”
2. Provide Only the Context You Need
Adopt the principle of least privilege for your context:- Share only the snippet that’s directly related to your question.
- Exclude unrelated files (e.g., CSS or frontend templates).
- Start minimal, then iterate if you need more detail.
Begin with the smallest code snippet that reproduces the issue, then expand only as necessary.
- Submit a targeted snippet.
- Evaluate the response.
- Add relevant code if the answer is incomplete.
- Refine your question to remove any noise.
3. Treat Web Searches Like LLM Queries
Search engines and Q&A sites respond best to precise, action-oriented queries:- Include the framework, library, and desired outcome.
- Example: “React hook for fetching API data with loading and error handling.”
- Iterate: refine keywords, add sample code, or specify browser support.
4. Iterate and Refine
Think of each query as a draft:- Review the LLM’s response.
- Add or remove context based on accuracy.
- Clarify output requirements (e.g., “Return JSON only”).
- Leverage external references and official docs for edge cases.
Thank you for following this demo. In our next lesson, we’ll dive into editing and debugging techniques for AI-generated code.