Gabriel Wyner's book Fluent Forever (2014) recommends using cloze deletion tests for learning grammar. Anki has a card type for cloze deletion tests (simply called "Cloze"). When creating a cloze test in Anki, first enter the complete sentence, select the part that will be invisible, and click the "Cloze" button. Most importantly, the point of using cloze deletion tests based on real sentences is that you acquire the grammar rules subconsciously through repeated exposure to examples. For this reason, you will need several examples for each grammar structure.
Where can you find example sentences? You can find those in textbooks, grammar books (example sentences below the grammar rules) and other language materials. Gabriel Wyner has a YouTube video "Anki Tutorial 6-Abstract Words and Grammar" that covers this. This video shows how you can use the "All-Purpose Card" type for cloze deletion tests: you use something like two underscores to replace the deleted words, so you have a number of other fields for the solution, hints (or definitions) etc. You can even add pictures. (In fact, you can also add pictures to the first field of the "Cloze" card type. Wyner does not mention the "Cloze" card type in his video.)
In his tutorial, Wyner uses a search engine to find example sentences, but he does not mention an interesting trick you can use to limit your searches to a specific domain. In many search engines, such as DuckDuckGo and Google, you can add e.g.
site:fr to a search to limit searches to French sites (i.e. sites whose domain name ends with "fr"). This can slightly reduce the risk that you pick up example sentences that were not written by a native speaker. (You'll need to know the relevant country codes, which are defined in ISO standard 3166-1 alpha-2.)
The website for the book Fluent Forever had a help section on learning grammar, e.g. How Can I Learn Phrasal Verbs?.