If you want to compose in the baroque style, the most logical thing to do would be to research how composers like Bach learned how to compose when they were young and then for you to use the same pedagogical methods that they did.
J.S. Bach himself taught his students in this way: his students would learn how to harmonize chorale melodies which they would be given. At first, Bach would provide a bass part to the given chorale melody and the students would have to fill in the tenor and alto parts. Later on, the students had to compose the bass part themselves.
But more importantly, composition students in the Baroque era were taught the practice of thorough-bass. This was an accompanimental practice where the keyboardist was given a bass part (played in the left hand) that included figures which indicated which harmonies to play in the right hand. This right-hand part was essentially improvised (but in accordance with the underlying harmonic structure and the rules of composition). The student was required to learn the principles of composition (voice-leading, preparing and resolving dissonance, etc.) so thoroughly that he was able to apply them in real-time when improvising these thorough-bass accompaniments. The whole point of composition students learning this practice was so they assimilated the rules of composition so thoroughly that they became second-nature.
There are various treatises which teach one how to learn the practice of thorough-bass, but perhaps most relevant is Friedrich Erhard Niedt's "The Musical Guide". There is evidence that J.S. Bach used this treatise when teaching his students. Besides this, you can find plenty of modern resources on this subject as well.
As for the best way to improve your skill at composition, it would no doubt be through practicing the skill of improvisation; a skill which many of the greatest composers excelled at (including Bach, Mozart, and Beethoven). Learning how to improvise is like learning how to speak a language fluently (as opposed to merely learning how to read and write in that language). The more you practice improvisation, the more naturally that musical ideas will come to you. Improvisation is a powerful tool to generate musical ideas, allowing you to try out different ideas very rapidly, allowing you to hear them in real-time before you write those ideas down. Improvisation is a skill like any other in that it needs to be practiced; you get better at improvisation through actually practicing it. If you have not practiced improvisation before, start by trying to improvise very simple melodies, making use of just the I and V chords, then move on to more complex ideas as you gain experience.
This was the advice that C.P.E. Bach gave: to become a good composer, it's better to learn how to be great at improvisation than to study the rules of composition (that is, studying through reading and written exercises). This was his reasoning: if you become great at improvisation, then it's merely a matter of writing down what you improvise at the keyboard in order to make a composition out of that improvised material. However, if you were only to learn the rules of composition through reading and written exercises, then you still wouldn't have gained the invaluable skill of improvisation through this kind of study. In other words, you naturally learn the rules of good composition by learning how to improvise well.
If you have any questions about anything I mentioned, feel free to ask.