I often get code suggestion as a git patch/diff, if it’s a file I could download it then run:

git apply file-name

But sometimes I could get it as an inline diff, in that case I might copy the diff, create a file then repeat the step above or manually apply the diff.

Today I found out how I might be able to apply directly from the clipboard using pbpaste command line utility on macOS.

So I can copy the diff then run:

pbpaste | git apply -

Reference