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.

What it breaks and what it brings

Changes are not good or bad and not every success means perfection.

Some will revolutionize your habits, your workflow. The good or bad perception of the change depends surely on your own experience, your functioning.

Since recently I've turned my smartphone and laptop screens to grayscale.

Is it any good or better ? Sure, for making everything more boring and fight screen addiction, it helps. I also turned Dark mode on in every app and websites that support it. And even this blog now is turned black & white, for the best I hope.

Changes can break compatibility, readability, harm productivity for instance I had to restore colors just for when my little one watches videos or when I edit some colorful documents we share with my partner. Using Grayscale the web extension on my Brave instance also caused my screen to blink a lot and I had to find an alternative. After a few days of experimenting with grayscale on all my devices, I really enjoy the experience especially in public areas, and I tend to find colorful screens more painful to watch.

Another example is that I use SyncThing with success for keeping my Obsidian in sync between my mobile and my laptops. It worked great at first, but then things mixed up between Obsidian Git based Sync and SyncThing, and I almost lost weeks of work. As a result I limit Git based sync solely to one instance of Obsidian, and also had to tune SyncThing to ignore some changes (similar to .gitignore).

Speaking of Obsidian, I'm recently starting to use Dataview a lot for generating dynamic content in notes with content extracted from other notes. It works super great but cumulating multiple dataviews in a document makes everything quite slow. Yet I'm not giving up on them, with time I'll find solutions.

In the end, it's a matter of tradeoffs, and be able to try, evaluate and adjust to your needs.

Charting my journey away from Big Tech: Embracing Privacy and Self Hosting Solutions

In my quest to get rid of GAFAM and decrease as much the tracking I'm subject to, I'm only at the start.

Social Media Alternatives

By the end of 2021, fed up with infinite news feeds, I've removed my Facebook, Twitter and SensCritique accounts with almost no alternatives. I needed to declutter and focus on my family, so I also reduced the influx of information by stopping RSS feeds, Newsletter subscriptions, by pausing notifications of most apps like WhatsApp, and of course I've stopped watching TV Shows & Movies, news... Those initiatives were also motivated by family augmentation as I became father in 2021 πŸ™‚

Anyway I had to pursue efforts !

Recently I've also removed Pinterest and I've set up Pixelfed (self hosted) to replace IG (Instagram). I've also joined a Mastodon instance as a replacement for Twitter. The good thing with Mastodon and federated networks is you can be on any instance and follow users from other instances. From my Pixelfed (IG-like) I'm subscribed to my Mastodon page (Twitter Like) and I'm also followed by my WordPress page thanks to the ActivityPub plugin I've setup on this blog. I've migrated my secrets from Bitwarden to Vaultwarden (self-hosted), my code from Github to Gitea (self-hosted), my WordPress and Shaarli from OVH to Cloudron running on Contabo VPS. I've also started using Nextcloud and Collabora as replacements for my "Office" suite (Google Docs, Google Sheets, ...) but I'm not yet sold to the UI.

Self-Hosting Tools

The goal is to try to use as much self-hosted tools as I can. It's not easy to find good alternatives especially if you care about usability, data portability, privacy, and connect with other users ...

I'm struggling to get rid of YT (Youtube) and YT Kids. There are plenty of alternatives to YT, but not so much with both a kid-friendly UX and possibilities to filter content.

Challenges in Replacing YouTube

The problem is not to find a privacy respecting alternative tool to YT : It's easy to find and host content on Peertube but not so much to find a good instance with interesting content.

The problem is most of the popular and interesting content is on YT. There are alternatives frontends like Invidious, SkyTube (Android), Clipious (an Android client for Invidious instances). But Invidious does not yet support filtering of videos, which make it an unsafe place for kids. At least SkyTube allows for filtering channels and that's what I'm gonna try with my kid, but the UX is lacking behind YT and that makes it quite difficult for my little one to navigate alone in the app and pick a video.

Future Goals and Challenges

Important next steps for me are to get rid fully of any Google software, that includes Gmail (this will be a though one), Youtube, Contacts, Calendar, Google Drive, Google Keep, Google Maps, etc. and to stop using software that depends on tech giants or trackers. Not easy. Just try surfing the web using Big Tech Detective extension. Even search engines or browsers that claim to respect your privacy are tracking you or rely on GAFAM infrastructure or trackers.

For instance, when trying to use DuckDuck Go search engine with the Big Tech Detective extension on :

Exodus on Android shows that most of the "privacy" friendly browsers on Android are full of trackers : DuckDuck Go, Ghostery, Firefox, Opera, Tor Browser... Only Brave on mobile didn't contain tracker, according to Exodus. The spyware watchdog catalog will provide additional data about some of the mentioned browsers while also claiming Brave is to be considered as spyware.

Fortunately there exist search engines alternatives, such as Mojeek (which uses its own index) and SearX.

While looking at my expenses and optimizing my budget, I've removed my Medium subscription, Pluralsight, and OpenAI subscription, and started to cancel hosting plans as I'll host most of what I need on my VPS. Next challenges would be to get rid of Netflix, WhatsApp, Amazon (Prime, Kindle...), Apple, Spotify, Dropbox (to Nextcloud?), ChatGPT (I've yet to find a comparable alternative) by looking for alternatives or privacy friendly frontends for what cannot be easily replaced. But they do not make it easy. By trying to get rid of Netflix, I've noticed that as the "main" profile of our family shared account, it's impossible to delete my data. I can only create a new Netflix account and transfer the family profiles to that one. At the end, I'd like also to replace my OnePlus One with a dumb phone or a fair phone. I had a look at privacy friendly OSes we can setup on Android but the compatibility with OnePlus 10 Pro is still work in progress. Anyway if you are interested, take some inspiration here. I also want to fix this blog by taking inspiration from Small Web and Slow Web philosophies. , works for future browsers or at least relies on libre JavaScript (see also LibreJS) or no JavaScript at all.

And also to convince my loved one to try free and open source software on her devices (Apple πŸ™‚ ). Lot of friends and family are using Whatsapp while I'm sold to Signal or alternatives. This one will be difficult to bypass. I aim at least to automatically backup all WhatsApp files to my Nextcloud.

Every small improvement towards more privacy, data portability, open-source, data ownership, freedom, will be worth it and I'll share my findings with you πŸ™‚

Web (browser) extensions I recommend

  • LibRedirect a web extension that redirects YouTube, Twitter, TikTok, and other websites to their alternative privacy friendly frontends. You can find my settings here.
  • Privacy Redirect a simple web extension that redirects Twitter, YouTube, Instagram & Google Maps requests to privacy friendly alternatives.
  • DuckDuckGo Privacy Essentials includes tracker blocking, cookie protection, DuckDuckGo private search, email protection, HTTPS upgrading, and much more. I use it to generate temporary email addresses when my email is requested.
  • Ultrablock blocks ads, trackers and third party cookies.
  • Privacy Badger blocks invisible trackers.
  • Terms of Service; Didn't read get instant information about the terms and privacy policies of websites you browse!
  • Undistracted - Remove distractions and simplify the web interfaces of popular platforms and social media like Facebook, Twitter, YouTube, Netflix, Instagram, Reddit, LinkedIn.

Web (browser) extensions I'm Trying

  • JShelter An anti-malware Web browser extension to mitigate potential threats from JavaScript, including fingerprinting, tracking, and data collection! But it causes some crappy websites to malfunction πŸ˜‰
  • Big Tech Detective helps you track tech giants. If fully activated, you won't be able to browse certain websites and even some supposed privacy friendly tools, such as Duck Duck Go Search engine which behind the scene rely on Microsoft infrastructure and hard partnerships with Microsoft.

Android apps I recommend

  • Exodus an app that audits Android apps for trackers.
  • F-Droid a installable catalog of FOSS (Free and Open Source Software) applications for the Android platform.
  • Aegis Authenticator : a free, secure and open source app to manage your 2-step verification tokens for your online services.
  • Dsub (download and install manually) as Navidrome client so I can get rid of Spotify.

WordPress plugins I recommend

  • ActivityPub With this installed your WordPress blog itself functions as a federated profile, allowing to reach a wider audience.

Tools I recommend

  • Kill the Newsletter Convert email newsletters to RSS feeds.
  • Bitwarden which is a password manager. I'm hosting Vaultwarden which implements the same API. Bitwarden client is available on any popular platform.
  • Invidious to be used as frontend alternative to YouTube. Same content as YouTube. No ads, no trackers.

Some reading I recommend

Self hosting providers

  • I recommend Contabo (no sponsor here), that I've hand picked among many alternatives, while choosing a good VPS offering at good prices. Only downside is their administration panel UX, but other than that, it was cheap. And they buy green energy to run their servers. The alternatives I had compared Contabo with were OVH (way too expensive) and Hetzner (cheap but unfortunately their VPS hardware lacks AVX support thus is not compatible with Cloudron requirements). Contabo in the end beats VPS offerings of Hetzner and OVH at that price, with more storage and CPU for me !

Self hosted apps

  • If you own a dedicated server / VPS, try Cloudron, it's such an easy way to self host your apps and take control of your data ! I'm currently using it with Nextcloud, WordPress, and all apps mentioned below below :
  • Wallabag as read-it later app but their search engine is archaic and cannot find anything. I better find a way to query their DB directly or drop the tool for something else.
  • Calibre as web e-book reader and e-book collection organizer so I can progressively get rid of my Kindle.
  • Navidrome as a replacement for Spotify as a streaming/music player and scrobbler.
  • Miniflux minimalist and opinionated feed reader. It's a pleasure to use.
  • Vaultwarden unofficial Bitwarden compatible server.
  • Changedetection.io free open source website change detection, website watcher.
  • PrivateBin minimalist, open source online pastebin where the server has zero knowledge of pasted data.
  • Invoice Ninja Invoices, Expenses and Tasks built with Laravel, Flutter and React.
  • Gitea a self-hosted Git hosting service that offers code hosting, code review, team collaboration, package management and CI/CD features. It is compatible with GitHub Actions, Docker, various databases and tools, and supports multiple languages and architectures.
  • Pixelfed a replacement for Instagram as it used to be (without all the ads, and crap).
  • Shaarli personal, minimalist, super-fast, database free, bookmarking service. Useful for sharing links or keep them safe and private.

Concluding Thoughts

I hope these insights and recommendations help you in your journey towards a more private and self-reliant digital life. As always, I’m eager to hear your experiences and suggestions. Let's make our digital space a bit more ours!