mirror of
https://github.com/jbranchaud/til
synced 2026-07-06 17:20:33 +00:00
Compare commits
2 Commits
b873f86f5b
...
6ad376885b
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ad376885b | |||
| 0c4702be97 |
@@ -10,7 +10,7 @@ working across different projects via [VisualMode](https://www.visualmode.dev/).
|
|||||||
|
|
||||||
For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter).
|
For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter).
|
||||||
|
|
||||||
_1772 TILs and counting..._
|
_1774 TILs and counting..._
|
||||||
|
|
||||||
See some of the other learning resources I work on:
|
See some of the other learning resources I work on:
|
||||||
|
|
||||||
@@ -168,6 +168,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
|||||||
- [Monitor Usage Limits From CLI](claude-code/monitor-usage-limits-from-cli.md)
|
- [Monitor Usage Limits From CLI](claude-code/monitor-usage-limits-from-cli.md)
|
||||||
- [Open Current Prompt In Default Editor](claude-code/open-current-prompt-in-default-editor.md)
|
- [Open Current Prompt In Default Editor](claude-code/open-current-prompt-in-default-editor.md)
|
||||||
- [Resume Specific Session](claude-code/resume-specific-session.md)
|
- [Resume Specific Session](claude-code/resume-specific-session.md)
|
||||||
|
- [Stash The Current Prompt To Send Another First](claude-code/stash-the-current-prompt-to-send-another-first.md)
|
||||||
|
|
||||||
### Clojure
|
### Clojure
|
||||||
|
|
||||||
@@ -716,6 +717,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
|||||||
|
|
||||||
### LLM
|
### LLM
|
||||||
|
|
||||||
|
- [Count Number Of Tokens In A File](llm/count-number-of-tokens-in-a-file.md)
|
||||||
- [Send cURL To Claude Text Completion API](llm/send-curl-to-claude-text-completion-api.md)
|
- [Send cURL To Claude Text Completion API](llm/send-curl-to-claude-text-completion-api.md)
|
||||||
- [Use The llm CLI With Claude Models](llm/use-the-llm-cli-with-claude-models.md)
|
- [Use The llm CLI With Claude Models](llm/use-the-llm-cli-with-claude-models.md)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
# Stash The Current Prompt To Send Another First
|
||||||
|
|
||||||
|
I've been working my way through the current cohort of Matt Pocock's [Claude
|
||||||
|
Code for Real
|
||||||
|
Engineers](https://www.aihero.dev/cohorts/claude-code-for-real-engineers-2026-04).
|
||||||
|
The best part about going through a series of videos like this is being able to
|
||||||
|
pick up big and small tips and tricks from another person's workflow.
|
||||||
|
|
||||||
|
One of the small things I picked up in an early video is the ability to stash
|
||||||
|
the current prompt.
|
||||||
|
|
||||||
|
Let's say I've gone to the trouble of writing out a detailed prompt, `@`'ing
|
||||||
|
some files, and so forth. Then I realize I need first prompt Claude to do
|
||||||
|
something else first. Instead of copy-pasting that prompt into my notes,
|
||||||
|
deleting it, issuing a different prompt, and then pasting it back in, I can hit
|
||||||
|
`Ctrl-s`.
|
||||||
|
|
||||||
|
`Ctrl-s` will _stash_ the current prompt, clearing out the prompt input. I can
|
||||||
|
then type in something else. Once I hit enter for that new prompt, it will be
|
||||||
|
sent to Claude and the stashed prompt will be immediately populated back into
|
||||||
|
the input.
|
||||||
|
|
||||||
|
Though `Ctrl-s` is mentioned when you hit `?` from within `claude` session, I
|
||||||
|
don't see it documented anywhere in their [Interactive Mode
|
||||||
|
reference](https://code.claude.com/docs/en/interactive-mode).
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# Count Number Of Tokens In A File
|
||||||
|
|
||||||
|
Over time you have accumulated a bunch of small directives, corrections, and
|
||||||
|
project details in your `CLAUDE.md` or `AGENTS.md` file. The file doesn't seem
|
||||||
|
too big, but you are mindful that it is being included in every prompt. How many
|
||||||
|
tokens is it eating from the context window?
|
||||||
|
|
||||||
|
OpenAI's BPE (Byte Pair Encoding) tokenization library,
|
||||||
|
[`tiktoken`](https://github.com/openai/tiktoken), is an open-source Python
|
||||||
|
package. If it is installed on our machine, then we can use it as part of the
|
||||||
|
following one-liner to check a file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
❯ python -c "import tiktoken, sys; print(len(tiktoken.encoding_for_model('gpt-4o').encode(open(sys.argv[1], 'r', encoding='utf-8').read())))" \
|
||||||
|
AGENTS.md
|
||||||
|
1018
|
||||||
|
```
|
||||||
|
|
||||||
|
I ran this against the `AGENTS.md` file in a team project I'm on. It came out to
|
||||||
|
1018 tokens. This is a very good approximation based on the tokenizer trained
|
||||||
|
for `gpt-4o`. The tokenizers may vary a little from model to model, but the
|
||||||
|
differences for our purposes here are going to be negligible.
|
||||||
|
|
||||||
|
This one-liner gets the "first" argument to the command, reads it in, and runs
|
||||||
|
that string against the tokenizer. The length of the tokenized encoding is then
|
||||||
|
printed.
|
||||||
Reference in New Issue
Block a user