Work regular hours. The secret to productivity is routine, discipline, and sleep. That’s non-negotiable. So you’re going to have to set a base day. I like to work hard so in your situation I’d say a minimum day is 8-5 or 9-6. Then I’d build on that.

First thing to do is to make sure you’re working well in those hours. Don’t try to compensate for procrastination by sitting there longer. On the vast majority of days I will literally not do anything other than work when at my machine. Quitting social media massively helps, or at least logging out on your work machine and vowing never to log in. Delete the apps on your phone, or keep your phone in another room or powered down. Have two phones if you really need one to make/receive calls during the day.

You’ll have days when you’ve done less than you want. It’s tempting to work extra hours to compensate, but instead you should say “right, I screwed up by procrastinating today or making a bad call on proceeding down that problematic road to achieve X that soaked up a lot of hours, but tomorrow I’ll have another go and get it right.” Go to bed, try again.

The most important thing to learn is how to decide what to do. This is far more important than the number of hours, or your skill level. A great programmer writing the wrong code has zero productivity. This is the most important advice for getting things done: deciding what to do. Sam Altman said something along these lines recently, he’s bang on.

At this stage you’re junior and won’t be as productive as others. So you’ll want to work some extra hours if you’re ambitious. If you’re keen, I’d recommend working Saturday rather than more hours in the evening. It’s less stressful and you’ll get more done, particularly if no one is contacting you. And a Saturday day can be more relaxed, maybe you want to socialise and you just do half a day, maybe you work on a laptop in bed or in a cafe for a change, you’re the boss that day.

You need to skill up, technically and managerially/organisation-wise. One method is to devote an extra hour a day to learning some tech skills. For example, you have a git problem that costs you an hour. Write on your todo list - learn git - and that evening (or whenever you invest a few extra hours) you study git, make a cheat sheet. That investment begins to accrue. Other things you might consider: mastering IDEs or emacs, build tools, testing, dev methodologies, languages etc. An hour spent googling and reading blogs, stack overflow, watching screencasts, without any pressure to get other work done is remarkably constructive.

So the todo list: you need to learn to organise yourself. This will up your productivity and reduce the need for long hours. Read a few books: Getting Things Done, Rework, The Now Habit. These soft skills are so very, very, crucial.

Finally: take care of yourself. Junior devs tend to have more of a social life, and it’s important to enjoy yourself. But be aware of and invest in all these things: exercise, diet (minimise caffeine, sugary drinks/snacks), relaxation time, and more than anything: sleep. Sleep. Sleep. Cannot emphasise enough. If you’re going out late one day, that’s fine, but try to sandwich it with good nights of sleep either side.

This might sound like a productivity guide rather than answering your question, but essentially I’m answering a related question: how can you spend your time well so that you don’t need to work 12 hours a day, but get enough done and still enjoy your life?

There will times you have to break any routine or hours limit you have. In which case, that’s fine, but as soon as that period is over: have a rest, make a firebreak over a long weekend, then do a reset and get back into that routine.