Skip to content

Supporting Gemini Canvas #55

Open
Open

Description

@raymondsheh

Gemini Canvas (accessed via https://gemini.google.com and selecting "Canvas" from tools) can be used to generate projects in, e.g., HTML with embedded Javascript in response to simple prompts. These can then be refined over the course of a session. The user can edit the code alongside Gemini. The system works for smaller projects but tends to require careful management once you get to thousands of lines of code.

Although not as capable as dedicated AI-assisted coding tools, Gemini Canvas is highly accessible, especially to those who are not familiar with software development. This accessibility also does mean that it is likely a greater proportion of those generating code with Gemini Canvas would be unfamiliar with secure coding practices and unable to audit the code themselves. Simple instructions for referencing CodeGuard rules might therefore be quite helpful.

In my experience, the code generated by Gemini Canvas often has a variety of security issues. I can prompt it with a generic "Please check the code for security issues," and it does a reasonable job, but it would be nice to be able to have it specifically reference CodeGuard rules.

Gemini Canvas (at least the version I have access to) can't connect to MCP servers or directly reference skill.md files. An early attempt at simply pointing Gemini Canvas at the .md files of CodeGuard resulted in some sensible output, but on further investigation it turned out that Canvas was giving generic security recommendations rather than specifically referencing CodeGuard. When I asked it to give me specific CodeGuard rules/.md files that were referenced, it "hallucinated" references (that looked more like OWASP references, which I would expect to have appeared in the training data).

I've asked Gemini itself how to best incorporate rules like this into its code generation. While I do still need to test it, here is what it has advised.

  • It has a hard time pulling these kinds of things in via URLs and, it turns out, it can't actually crawl a file tree.
  • Attaching them is better but isn't emphasized.
  • The best option is to "flatten" the skill file (i.e., concatenate the skill.md file with the files that are referenced, separating them by "# file_name.md" headers). This should be quite doable as only a subset are used for, e.g., Javascript. It claims that this means that the rules are given higher attention.
  • It claims to be able to handle 20,000-50,000 lines of text in a single prompt.
  • It might periodically need to be reminded to follow the rules (e.g., with a prompt "Remember to stick to the CodeGuard rules for this edit") but it claims that it doesn't need to re-read the rules each time.

I'll continue having a play with this and report back if/how this works out.

Activity

  1. davidlabianca commented on Apr 28, 2026

    @davidlabianca

    Given the focus is Canvas - have you tried creating a custom Gem (see new gems view) that pulls in codeguard?

  2. raymondsheh commented on Apr 28, 2026

    @raymondsheh
    Author

    Thanks for the suggestion!

    I haven't yet, mostly because I've been working on the (possibly incorrect) assumption that gems are a bit like a macro to set up the first prompt of the session ... but I can't write that until I've figured out what that first prompt should be so that it reliably actually uses Codeguard (as it doesn't have hooks/etc., at least as far as I know).

    I should have a bit more of a play with gems though ... perhaps there is a difference!

    (FWIW right now I'm experimenting with the difference between pulling in subsets of Codeguard rules as files versus simply pasting them into the prompt ... in both cases, I totally agree that once we figure out a good method, turning it into a gem makes a lot of sense.)

  3. moved this from Needs Triage to Needs Decision in Project CodeGuardon May 12, 2026
  4. moved this from Needs Decision to Needs Triage in Project CodeGuardon May 12, 2026
  5. moved this from Needs Triage to Ready for Owner in Project CodeGuardon May 19, 2026
  6. thomas-bartlett commented on Jun 9, 2026

    @thomas-bartlett
    Contributor

    @raymondsheh I did a bit of searching, and I don’t see Gemini Canvas currently supporting skills, rules, MCP, or an equivalent integration mechanism. The closest option appears to be a custom Gem with instructions and uploaded files, but that seems more limited than the tool integrations CodeGuard supports elsewhere.

    Do you think there is still value in documenting a lightweight Gemini Canvas workflow for CodeGuard, perhaps using a Gem or uploaded rule bundle? If not, I think we can close this issue for now.

  7. moved this from Ready for Owner to Needs Triage in Project CodeGuardon Jun 16, 2026
  8. raymondsheh-NIST commented on Jun 16, 2026

    @raymondsheh-NIST

    @thomas-bartlett You're right that the integration is somewhat different from "normal" agentic code generation tools but I've done a bit more poking around given that there has been a significant update in Google Gemini since the last time I tried this. While I would still need to download the relevant SKILLS.md and other CodeGuard rule files and then attach them to the session, it looks like I should just be able to point at them.

    I'm currently working on a gem to do this ... the sticking point of course is that Google Gemini Canvas doesn't have hooks or similar, I'm trying to figure out a way to test if the CodeGuard rules are actually firing. My earlier tests mentioned above were somewhat ambiguous as there is overlap between what the CodeGuard rules state and good coding practices that Google Gemini already knows ... I would assume that CodeGuard itself predates the latest update to Google Gemini that we might have a second-order issue in that it would be difficult to tell if the uploaded CodeGuard rules are firing, or if it's using CodeGuard rules that it might have ingested in the latest training round (which would look identical in behavior but wouldn't update when CodeGuard updates, at least until the model retrains).

    I'm continuing to have a play but I think this problem is common to the other ways CodeGuard is used - even if hooks are used and we know that the agent looked at CodeGuard, there's still the need to test that the rules were used properly.

  9. moved this from Needs Triage to In Progress in Project CodeGuardon Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions