Self-answering in general
As linked by DJMcMayhem in a comment, prior consensus is that self-answering is fine as long as you wait long enough for some other answers to come in. If it sits unanswered for long enough then it's fine to post your answer anyway, since apparently there aren't any other answers to discourage.
Specifics of motivation
I see no issues with a pattern like:
- Discover a neat, golfy piece of code that does something interesting
- Discover that there is no existing challenge for that interesting thing
- Write a challenge to do that interesting thing
- Eventually post your code
One thing I would avoid is having "what my piece of code does" be the final arbiter of correctness. To put it another way, if you find that your code has bugs, you should fix those bugs rather than mandate that all other solutions replicate them. Sometimes it's not a big deal (e.g. there are two equally valid ways to rule an edge case), but if you start having to make weird exceptions or special-cases to keep your own answer valid then I think that's a problem.
Another pattern you might use is this:
- Think of a problem you want to golf
- Discover that no existing challenge is close enough to that problem for your tastes
- Write a challenge to solve that problem
- Start golfing
I can't really imagine an issue with this process, but even if you don't start golfing before posting the challenge it's still a good idea to let others post the first answers.
Note that in both of these patterns, steps 2 and 3 are important. In step 2 you might discover that you need to change the challenge to avoid being a duplicate, or that you don't need a new challenge at all. In step 3 you should make use of the Sandbox to get feedback ahead of time; this might even cause your first answers to come faster since other golfers can get their own presolving time as well.