Structure Prompts for Both Code and Explanations
Last updated
Last updated
Since Nyvo generates not just on-chain code but also off-chain code (and possibly even deployment scripts or config), it helps to structure your prompt so the AI cleanly outputs multiple components. For example, you might instruct: “Provide the Anchor program code and the React front-end code, each in separate markdown code blocks with appropriate file names or comments indicating the file.” This tells the AI to organize the response in a readable way. Some prompting patterns to consider:
File-by-file prompts: If you want the output separated (one for program.rs
, one for App.jsx
, etc.), explicitly ask for that. For example: “First, show the Solana program code (Rust, Anchor) in a rust code block, then the front-end code in a
tsx block.” The AI can sometimes follow such formatting instructions to make the result easier to navigate.
Ask for comments and docs: To help you understand the AI-generated code, include in your prompt “Add comments to explain each major section of the code” or “Include docstrings or inline comments for clarity.” Well-commented code is easier to debug and maintain. Nyvo’s output can then serve as not only code but also a bit of documentation for you. For instance, asking the AI to // explain why certain checks are done
in the code can yield helpful inline comments.
Specify frameworks/libraries: Solana development often involves specific libraries (e.g., @solana/web3.js
for JavaScript, anchor-lang
for Rust, or Metaplex APIs for NFTs). If your dApp needs an integration (for example, using the Metaplex NFT standard or Serum for a DEX), mention those by name. This ensures the AI brings in the correct usage patterns or SDK calls in the generated code, rather than something generic.
By structuring your prompt and including these details, you’re effectively giving the AI a blueprint to follow. It can then fill in the sections with code accordingly, increasing the chance that nothing important is omitted.