Colleague claiming first co-autorhip of my work Some time ago I started my Ph.D. and my project was to attempt again to investigate a problem that a colleague (a senior Ph.D.) had failed to investigate because he lacked numerical/coding skills to attack the problem. Essentially our advisor put me to work on a line of research that senior phd had abandoned, and I started from his (few) old results, spent 9 months writing code and running the simulations, and finally obtained some interesting results. Senior PhD, though he mostly contributed with discussions and one plot, casually claimed co-first-authorhip by asking to our advisor when I was not there, but the request was refused.

For the last 6 months we worked on a natural continuation of the previous research. Senior phd insisted to collaborate intensely at the beginning and for the first month we surely did, but later he was caught by other things (writing 2 other papers, writing the PhD dissertation..) and I continued my work alone with a PostDoc. SeniorPhd always attended discussions. 

It is now time to start writing the paper, and he said he would write it, as he has alredy written part of those results in his dissertation and because he writes faster than me (so we can publish before other groups) . I politely refused during the meeting, so he offered to co-write the results with me.

Our advisor ignored the issues and pushed to move onto other topics.

After that meeting, senior Ph.D. started to ask me to explain a few things that he still did not get about the method, and I explained him. He then proceeded to make a few very quick simulations to produce the first 2 figures of the paper and presented those to the PostDoc a few hours after I was done explaining him.

I felt as if he is trying to force himself as first author/coauthor by simply starting to write a research in which he did not do the majority of the work. 

All the data is in a shared drive, so in principle, he could write everything up.

How can I confront the issue without looking like an asshole who refuses to be helped by a very kind collegue?
First, I know the struggle is real. One of my three wishes would certainly be for us to somehow separate career and prestige from the collective pursuit of knowledge. 

There's an expression I recall from redneck NASCAR culture that seems relevant here: "Rubbing is racing." There will always be some pushing and shoving concerning who did what, particularly as scholars are trying to jump from fledgling academics to something tenured. If it's a little irritating, I'd just keep pursuing knowledge. 

If it's more than a little and you feel as though you are not being treated fairly, then I encourage you to not care about how others perceive your bringing it up. The higher we climb, the less accurately we seem to predict how supervisors will respond. So why worry about that? If he's getting undue credit, speak up; if he kind of deserves some credit, why split hairs?