Prompt hacks aka make the best coding out of GPT

I've been using a paid subscription to ChatGPT Plus since May 2023 and I'm still happy with the usage. It's one of those tools you have to master to get most of the time spent with it. There are a lot of benefits to use it, of course there are also negative aspects and bugs. Some of them can be mitigated, and that's the purpose of the current post.

Disclaimer / Context of use 🧾

  • I'm ChatGPT mostly for scripts and each conversation is focused on singular topics, i.e single-file codebases if possible.
  • I don't use Open API Keys and I'm not interested to use OpenAI directly. I've been on a paid plan for OpenAI and was charged way too much for my needs. I advise anyone to use ChatGPT Plus which remain to this day worth it and good enough both for personal and professional.
  • This article was not written nor reviewed by AI/ChatGPT.

Lessons learned - Do βœ…

  • Test test test after each change. ChatGPT will make you lose faith by repeating the same mistakes, by removing sensitive code, by providing incomplete solutions, always verify.
  • Before running or committing anything generated by ChatGPT, always compare with the previous situation you had. Git diff the result of changes. If you have any doubt about a specific change, submit the git diff to ChatGPT for review and ask for explanations while also explaining why you have doubt (failing tests, errors at runtime, weird code removal, ...).
  • Tell ChatGPT to always decouple code in functions.
  • Instruct to use minimalist code, and avoid comments in code, respect your specific style (if you provide examples), instruct to write the code that takes the least amount of lines and space and to avoid long functions.
  • Keep one conversation per context / type of problem / flow. Once done with the problem, validate the solution (test!), commit locally, and delete the conversation to keep your Chat history clean.
  • Try to limit ChatGPT's attention to one single file or one single function at a time, to improve its speed and accuracy. I've experienced inconsistencies and code regressions when expecting ChatGPT to work with too many files and too many changes at once on too many files, as then ChatGPT.
  • If you have lot of work you expect ChatGPT to perform for you, be patient and request one change at a time, then review the outcome, and only if it's validated, move to the next. ChatGPT sucks at multitasking. Keep the rest of your TODO list somewhere else to keep track of what remains to be requested from ChatGPT.
  • You will be given better results if your tech stack relies on popular libraries and programming languages so keep that in mind and be prepared to deal with more mistakes if you pick niche programming languages.
  • Ask to only output the code that require change, e.g add this at the end of your prompt :
    just output the function(s) needing change
  • If you really want to multitask, open multiple ChatGPT sessions (browser tabs) in parallel, each focused on distinct changes, so you can multitask while ChatGPT stays focused on single tasks πŸ™‚
  • One change at a time. If ChatGPT keeps making error, step back, restart from to the latest stable version of your code, and ask to make minimal changes, step by step, while you validate each increment.
  • When happy with your changes, ask ChatGPT to improve its performance or clean the code.
  • When debugging your code with ChatGPT, provide stack traces, inputs, outputs and even complete your input with the copy of the code that seems buggy (based on the stack trace).
  • Be suspicious if ChatGPT changes your code way too much or introduce weird changes to dependencies. Review, check, investigate.

Lessons learned - Avoid ❌

  • Don't run nor commit anything generated by ChatGPT that you don't understand and always compare ChatGPT's solution with what you had before.
  • Don't ask too many improvements or bug fixes at once or be prepared to deal with many new errors and regressions.
  • Don't keep conversations for too long, as all the initial context will likely be forgotten about by ChatGPT and you will suffer, also it will cause a lot of scrolling and augment the size of the web page which will be slower to load and will likely crash your browser tab at some point.
  • Don't switch context / files / problems in the same conversation. It's a waste of time and you will suffer later when trying to source specific content or make sense of anything.
  • Don't share secrets/passwords with ChatGPT.
  • Don't waste your time with ChatGPT if it seems unable to solve your problem. Either your problem is too big, either your input is crap, anyway you will likely move faster by starting from a fresh conversation with a smaller problem or by tackling a specific part of the problem on your own. Be confident in your own abilities.
  • Don't expect ChatGPT to be as efficient on big codebases and complex problems as it is on small scripts and simple problems. So use it more often for the latter and keep the fun of solving the big problems yourself.
  • Don't expect ChatGPT to understand a single thing you do nor why he generates his code. it's a dumb machine without creativity built in. It has to be treated as such and with caution.
  • Don't expect ChatGPT to run well and fast on huge bloated scripts. That should encourage you to decouple your code into functions and modules and specialized files/modules/components/...

Relevant references

  • I consider ChatGPT eases automation to the point those XKCD memes are less relevant than they used to be.
Automation (by XKCD)

Legend: "I spend a lot of time on this task. I should write a program automating it!"

via https://xkcd.com/1319/

is It Worth the Time? (by XKCD)

Legend: "How long can you work on making a routine task more efficient before you're spending more time than you save? (across five years)"

via https://xkcd.com/1205/

Extras

  • If you lose focus on the ChatGPT session in your browser, it's likely the calculation process will interrupt.
  • ChatGPT seems stuck at generating the output ? Refreshing the page might be enough, in other cases ChatGPT might automatically continue the generation or will show a button you can hit to force this action.
  • I've commented on this topic and this post at https://lobste.rs/s/7a3qhh/how_s_your_experience_so_far_using_llms_for#c_igssaj

Thank you πŸ™‚


Last updated: June 26, 2024 around 8:24 PM CEST in πŸ—ΊοΈ Brussels, Belgium.

Quick Bugs, Slow Fixes

The tortuga engineer has good guts but often seems slow compared to the rabbit engineer.

The rabbit engineer is quick at decision and gives impression of progress to the product owner often disappointed with the slow pace of change of the tortuga.

The tortuga is busy battle testing the draft he's about to integrate in the product, suddenly he finds out the new bugs were introduced recently by the rabbit, and decides to postpone his work while focusing on debugging the shit.

In the meantime, the customer complains because of the new bugs introduced in latest release by the rabbit engineer.

The product owner is worried and decides fixing this bug is a priority.

The tortuga engineer was already investigating the bug and proposes a fix.

The rabbit engineer cannot wait for the tortuga to fix the bug and already merges new changes in the stable branch so the new release will not only be bug free but also deliver new quality shit.

The tortuga is busy integrating and retesting all the new changes made by the rabbit as it seems those changes includes critical changes of the core authentication layer and library updates that had nothing to do with the features the rabbit was working on. And those changes break things.

The rabbit becomes impatient at the slow tortuga and decides to create a hotfix and deliver his changes to production.

The customer is still unhappy.
The product owner finds the tortuga slow. and indecisive and is happy the rabbit already can deliver a fix from his machine tonight while the tortuga will be busy with kids at home.
The rabbit says tortuga is not working hard enough.
The tortuga is tortured with all the shit that is being merged in the codebase by the rabbit.
The rabbit says it's time to hire more people and he knows other rabbits who can help and it would be nice if the tortuga worked more like rabbit is doing.

The tortuga suggests to focus on quality and teamwork and slow down but the rabbit and the product owner look at him suspiciously.

The product owner suggests the tortuga to leave the team if he's not happy with the way things are. Because here where we work, speed is important even if results are not perfect.

"fuck this shit man".

A few weeks later, tortuga has left.

The tortuga is working in a good team nowadays, where testing is a thing, quality is under control, documentation matters, and collaboration is a foundation.

Reflections on Change: The Constant Shuffle

Change is a constant.

I passed 37 years recently.

In 2022 I was going freelance after 12 years of employment. Why ? Because I had been so disappointed by many years of employment, bad managers or politics, I needed to feel like I gave the credit myself deserves. I now feel after one year I would like to help and mentor other people to go freelance.

My toddler (2.5 years old) is going to school and I drive him at school by bike. The more I invest time with him that I don't spend at other crap, the deeper we connect. But crap is everywhere and trying to steal time from us. Seeing him growing so much reminds me of the time passing and the need for me to lead by example.

I learned from hundred of hours spent crafting my LinkedIn profile, sending/receiving tens of thousands of LinkedIn messages, crafting my resume, interviewing for hundred of jobs. No matter how long we play this game of finding the ideal job and finding the exact rates, conditions, etc we deserve and want, those variables keep changing a lot and are difficult to correlate with ideal job. In the end it's not about the job but about who we are, what we need from life, what we really want to do on a day to day, what kind of problems we like to solve, what kind of people we want to work with, what kind of team we want to shape. The ideal job is a rare combination of hidden variables and is a constantly changing problem that requires gut feeling and experience, like finding the perfect taste in coffee / espresso / beer is a never ending game.

As part of this I've removed a lot of my previous job criteria at to recruiters to keep things simple.

Outside of work, I also made a lot of sacrifices, at least choices that I regretted. For the sake of trying to please or do the right thing, I got in trouble a few times. In the future I have to stand for what is worth to me, and trust my gut feeling. I'm always willing to make compromises as I'm a Belgian and we excel in this ! but I also have to set boundaries and speak the truth and take distance at need. Before this post, I struggled to start writing. Speaking of which, I even thought of using ChatGPT to help with the task. ChatGPT has clearly influenced radically the way I interact with the web and the universe of problems, including code but not only. It drastically revived my interest into technology. But it also obvious there is a long way before AI can supersed us. A good tool is nothing without a creative mind and some persistence. And a good mind needs to express, otherwise it's best to just play sudoku alone.

And that motivates me to write. And I make no promises, but to write for myself πŸ™‚ and share things.

When working from home is toxic

Before the pandemic, one would regularly question whether working remotely could replace working in the office, and the lockdown helped to discover the pros and cons of each in the long term. The pandemic happened and suddenly legions of influencers advocates for work-from-home, trying to convince you that to get any work done, you should stay at home. As companies praise workers to return to the office, many employees have joined the great resignation. I'm happy that numerous workers have resigned from unsatisfying jobs and are looking for better work cultures, but I don't believe working in the office is the problem.

Recently, artist Irina Blok authored a few charts about working from home and the pandemic. And the one below really caught my attention as a parent and as someone subject to heavy mental load.

Irina Blok tweeted about remote working benefits during the pandemic. Someone else fixed it.

My concern with such a chart is that not everyone has a home office that looks as good as a traditional workplace. In addition, interruptions happen at home too and chatting with coworkers is not a problem per se. Hopefully, someone else in the internet partially fixed the chart for me. Working from home can have as much negatives as working in the office, and those can include things like :

  • Inconvenient office setup
  • Noise
  • Lack of private office
  • Mental load
  • Interruptions and distractions
  • Home office costs
  • Lack of socializing
  • Insufficient face time
  • Overworking
  • Increased sedentary lifestyle
  • Lack of room for self

Inconvenient office setup

At the office, you have your dual screen, a large desk, a comfortable chair, meeting and relaxation rooms, places for isolating yourself from your coworkers. On top of that, the internet connection is awesome and there are free snacks, drinks, fruits, and a top-notch coffee machine. If I want to mimic the benefits of working in a professional office, I'll need to invest in a bigger place and better material, or move to a co-working space.

Noise

In the last few months, our rental contract ended. It happened before the building of our future apartment could be achieved, as unfortunately the pandemic affected the whole construction sector. Our temporary solution was to rent a place via Airbnb. We are happy with the spot, however we ignored that the neighbors were renovating their place for the past 12 months. We have gotten used to it, but as hypersensitive persons, my partner and myself struggled a lot with this. We learned patience the hard way by being subject to intense noise any time of the day, any day of the week. Welcoming our new-born in this stressful environment was the last thing we wished, and often baby naps turn out to be impossible. When you need to work, it's the worst type of nuisance as you cannot focus. I simply prefer to stay muted in most Zoom meetings.

Lack of private office

In this Airbnb, I don't have any private space. I'm often working in the laundry/storage room, or at other times in the living room. It means that when the little one is sleeping in the living room, which is the next room, I have to stay silent and I'll stay muted in meetings or just skip them.

Mental load

Working at home means I'm even more aware of the household chores, and I'm thinking constantly about them from the beginning until the end of the work day, so it's harder to focus on anything else. In addition, as a new parent, I'm even more focused on others needs, i.e the constant well-being of my toddler. But while I'm trying to be 100% available as a parent and partner, I'm also very committed to my career. As a highly sensitive person (HSP), I do experience sensory overload and emotional flooding, and the home office is just too distracting for me. When I have to interrupt some work related task, I feel stressed as I tend to think that my colleagues spend 100% of their time working, which is unlikely of course, and I fear to be unproductive. And when I'm working, I feel it's unfair for the other parent to do parenting alone without any break or rest.

Interruptions and distractions

The mental load has consequences. When I leave my home office room, I become prone to be distracted by jobs to be done. While constantly switching between work and home tasks, it's harder to focus 100% on work. If I take a break and start taking care of the toddler or handling household chores, I might easily forget about the next meeting. As I'm at home, it's also easier to reach out to me for my partner, the family and other visitors. On the long run, those factors prevent any type of deep work, which is endangering productivity and motivation.

Home office costs

Who is paying the bill when you consume twice more energy for all your work devices, monitors, the light and the heating ? Who is paying for the internet connection, the coffee, extra drinks and meals, printing, writing material ? Since I've started to work 100% remotely, those costs have increased while remaining at my expense.

Lack of socializing

Among my Facebook network, 70% of my contact (excluding family) are people I've met in the office or during my studies. I'm not an extrovert, but I do enjoy social interactions. I'll likely start a discussion around the coffee machine or in the office corridor, or with a colleague in my field of view, and this creates opportunities that I'll miss while working remotely. In addition, if your company culture is not encouraging remote social interactions, you might feel as isolated as I was during the lockdown. In my last employment, the pre-lockdown era was 1 year and 2 months long, and it felt way richer and interesting than the following 1 year and 4 months period of remote working. I couldn't have the chance to meet my colleagues in person, and when you're the investigative and social type of person, you build way more energy, inspiration, satisfaction and motivation when interacting with people in person.

This period of 1 year and 4 months was a long time without any team building. It was also poor of opportunities to connect with the new joiners, the new boss and the team buddies. With a few exceptions, most of the meetings and discussions rotate only around work which is adding to the general stress of working remotely and contributed, among other factors, to ruin my motivation.

Insufficient face time

Even if face time still occurs, it's happening less often or at least with less than ideal conditions. Some tips can make it better, but video calls are a trade-off and not the solution. Zoom/Meet/Team calls will never replace the in-person interactions, especially if we take bad habits such as enabling blur effects or virtual backgrounds which give the feeling of talking to a floating face.

Overworking

The lack of work-life balance and suggested breaks are the point here. There is no emergency to close your laptop and start commute back home when you are already in your place. The temptation is great to keep working a bit more. Everyone can simply reach out to you more easily to get some work done. Of course you can find arrangements to keep yourself away from the work pressure, but it's just harder than when the physical separation was in action. It has never been easier than nowadays to connect to work from anywhere, and now you have to constantly remind yourself to resist the temptation. Reminding yourself that you are at home and not at work ? Easier said than done when both places are the same.

Increased sedentary lifestyle

It's up to me to fight this, anyway the daily commute in addition to the regular travels in and out of the office, to grab a lunch for instance, helped people like me to move way more often.

Lack of room for self

Sharing the same living and working space than your loved one is a gift but can be exhausting. In the long run, regular separation can be beneficial to having something like a reunion. Spending all your time in the same space as your life companion can be challenging as it means you have never time alone and you depend constantly on the other noises and moves. It is clearly not for everyone, especially when you are independent. The pandemic forced us to deal with this situation and we are flexible enough to survive. We even manage to give each other some time alone. However, staying at home all the time is not compatible with our need for autonomy in the long term.

Is it that bad to prefer working from home ?

Not at all. Wearing the hats of a parent and an employee, I am fully aware of the pros of working remotely, especially when it comes to productivity, flexibility, and parenting, and this will be the topic of a future post.

That being said, I'm advocating for working in the office, as I consider it has long term benefits for my career, professional network, work-life balance, socialization, productivity, teamwork and motivation. And I believe that working from home cannot beat those perks in the long run.

If you want to discuss, please comment πŸ™‚

Updates

When it’s time to quit your job

As cool as it could have been for a while, the moment comes when your steady job frustrates you. It can be because of a work culture and politics or because the pandemic made you reconsider if your job cost/benefit balance was positive and you might have joined the great resignation. Or the reason sits somewhere else.

For what it's worth, here is a quick tip I've been using to help me decide whether it's really time for me to change.

All you have to do is to answer the three following questions :

  • Do I enjoy my work assignments ?
  • Do I enjoy the company of my direct colleagues and my manager ?
  • Do I feel satisfied with my current salary package and benefits ?

If the answer is no for at least 2 out of the 3, then you have to seriously start interviewing for job opportunities.